electron/patches/node/build_only_create_cppgc_hea...

57 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 27 Nov 2023 17:23:29 +0100
Subject: build: only create cppgc heap on non-32 bit platforms
Node.js crashes during heap marking when using cppgc on 32 bit platforms. Disable for now.
Crash occurs in the following stack:
* MarkingVisitorBase<ConcreteVisitor>::VisitEmbedderTracingSubClassWithEmbedderTracing
* MarkingWorklists::Local::PushExtractedWrapper
* CppMarkingState::MarkAndPush
* CppMarkingState::MarkAndPush
* WrappableInfo::From
* Crash
See https://gist.github.com/codebytere/275ec8923253fd6559b3d36115f7b31b for more.
This should be fixed and re-enabled on all platforms.
diff --git a/BUILD.gn b/BUILD.gn
index 7d201bb6b822f0401c3be2bc52d65bc71463748b..38f4b5afb9e667f0958008847224fa7a6cfe64a0 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -181,6 +181,10 @@ config("node_internal_config") {
}
defines += [ "NODE_ARCH=\"$node_arch\"" ]
+ if (target_cpu == "x86" || target_cpu == "arm") {
+ defines += [ "NODE_RUNNING_32_BIT" ]
+ }
+
if (target_os == "win") {
node_platform = "win32"
} else if (target_os == "mac") {
diff --git a/src/env.cc b/src/env.cc
index 9f83720fefc77342dd45cdf1eebfac613262ad63..309b39fb2b1116824c0c1c2ae86d8e1113e31c3d 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -557,7 +557,8 @@ IsolateData::IsolateData(Isolate* isolate,
// for embedder ID, V8 could accidentally enable cppgc on them. So
// safe guard against this.
DCHECK_NE(descriptor.wrappable_type_index, BaseObject::kSlot);
- } else {
+ } else {
+#if !defined(NODE_RUNNING_32_BIT)
cpp_heap_ = CppHeap::Create(
platform,
CppHeapCreateParams{
@@ -565,6 +566,7 @@ IsolateData::IsolateData(Isolate* isolate,
WrapperDescriptor(
BaseObject::kEmbedderType, BaseObject::kSlot, cppgc_id)});
isolate->AttachCppHeap(cpp_heap_.get());
+#endif
}
// We do not care about overflow since we just want this to be different
// from the cppgc id.