summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-10-17 10:55:16 +0200
committerAndreas Kling <kling@serenityos.org>2022-10-20 15:16:23 +0200
commit2898701459a3966b3e973823706142ebbc287ae9 (patch)
treee5c08b52a956704910b523166ea78397dfdfe365 /Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
parent6e0f80fbe0f9ca5d411de4887d548c17cea11097 (diff)
downloadserenity-2898701459a3966b3e973823706142ebbc287ae9.zip
LibWeb: Hang on to the internal realm with a JS::Handle
This fixes an issue where GC would kill the internal realm if it ran at the wrong time during startup. Found by aggressively GC'ing between every allocation.
Diffstat (limited to 'Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
index a1fd290993..557a203a79 100644
--- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
@@ -375,6 +375,7 @@ JS::VM& main_thread_vm()
auto* intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm);
auto host_defined = make<HostDefined>(nullptr, *intrinsics);
root_realm->set_host_defined(move(host_defined));
+ custom_data.internal_realm = root_realm;
// NOTE: We make sure the internal realm has all the Window intrinsics initialized.
// The DeferGC is a hack to avoid nested GC allocations due to lazy ensure_web_prototype()