Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit475dab0

Browse files
committed
feat: optionally prevent calling V8::EnableWebAssemblyTrapHandler
1 parent434cd3d commit475dab0

File tree

4 files changed

+42
-136
lines changed

4 files changed

+42
-136
lines changed

‎patches/node/.patches

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ fix_handle_possible_disabled_sharedarraybuffer.patch
4242
win_process_avoid_assert_after_spawning_store_app_4152.patch
4343
test_fix_edge_snapshot_stack_traces.patch
4444
chore_remove_use_of_deprecated_kmaxlength.patch
45-
api_remove_allcan_read_write.patch
4645
fix_avx_detection.patch
4746
src_avoid_copying_string_in_fs_permission.patch
4847
chore_remove_allcan_read_write_from_setaccessor.patch
4948
fix_missing_include_for_node_extern.patch
50-
feat_enable_preventing_cppgc_heap_creation.patch
49+
feat_optionally_prevent_calling_v8_enablewebassemblytraphandler.patch

‎patches/node/feat_enable_preventing_cppgc_heap_creation.patch

Lines changed: 0 additions & 121 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shelley Vohr <shelley.vohr@gmail.com>
3+
Date: Thu, 16 Nov 2023 16:48:10 +0100
4+
Subject: feat: optionally prevent calling V8::EnableWebAssemblyTrapHandler
5+
6+
V8::EnableWebAssemblyTrapHandler can be called only once or it will
7+
hard crash. We need to prevent Node.js calling it in the event it has
8+
already been called.
9+
10+
This should be upstreamed.
11+
12+
diff --git a/src/node.cc b/src/node.cc
13+
index 89e0e5524c2102b86bc5506fe49aa0c6fa0f30c1..e58f28e0f0ff8d61f35ec3c5a69aa37c66c25d78 100644
14+
--- a/src/node.cc
15+
+++ b/src/node.cc
16+
@@ -605,6 +605,7 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
17+
#endif
18+
}
19+
#endif // defined(_WIN32)
20+
+ if (!(flags & ProcessInitializationFlags::kNoEnableWasmTrapHandler))
21+
V8::EnableWebAssemblyTrapHandler(false);
22+
#endif // NODE_USE_V8_WASM_TRAP_HANDLER
23+
}
24+
diff --git a/src/node.h b/src/node.h
25+
index 9ac0d5addcdd40d5c91d375b626099b95729548a..3ffc51783b0b6dee1c0f0a37d2f52cb1aec2fa3f 100644
26+
--- a/src/node.h
27+
+++ b/src/node.h
28+
@@ -272,6 +272,10 @@ enum Flags : uint32_t {
29+
// cppgc::InitializeProcess() before creating a Node.js environment
30+
// and call cppgc::ShutdownProcess() before process shutdown.
31+
kNoInitializeCppgc = 1 << 13,
32+
+ // Do not initialize the Web Assembly trap handler. This is used by
33+
+ // embedders to account for the case where it may already have been
34+
+ // initialized - calling it more than once will hard crash.
35+
+ kNoEnableWasmTrapHandler = 1 << 14,
36+
37+
// Emulate the behavior of InitializeNodeWithArgs() when passing
38+
// a flags argument to the InitializeOncePerProcess() replacement

‎shell/common/node_bindings.cc

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -515,18 +515,14 @@ void NodeBindings::Initialize(v8::Local<v8::Context> context) {
515515
std::vector<std::string> args =ParseNodeCliFlags();
516516
uint64_t process_flags =
517517
node::ProcessInitializationFlags::kNoInitializeV8 |
518-
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform;
518+
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform |
519+
node::ProcessInitializationFlags::kNoEnableWasmTrapHandler;
519520

520521
// We do not want the child processes spawned from the utility process
521522
// to inherit the custom stdio handles created for the parent.
522523
if (browser_env_ != BrowserEnvironment::kUtility)
523524
process_flags |= node::ProcessInitializationFlags::kEnableStdioInheritance;
524525

525-
// We do not want cppgc in the renderer process as it
526-
// would clash with Blink's initialization.
527-
if (browser_env_ == BrowserEnvironment::kRenderer)
528-
process_flags |= node::ProcessInitializationFlags::kNoInitializeCppgc;
529-
530526
if (!fuses::IsNodeOptionsEnabled())
531527
process_flags |= node::ProcessInitializationFlags::kDisableNodeOptionsEnv;
532528

@@ -608,13 +604,7 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment(
608604

609605
args.insert(args.begin() +1, init_script);
610606

611-
uint64_t isolate_data_flags = browser_env_ == BrowserEnvironment::kRenderer
612-
? node::IsolateDataFlags::kNoCreateCppgcHeap
613-
: node::IsolateDataFlags::kNoFlags;
614-
615-
auto* isolate_data =node::CreateIsolateData(
616-
isolate, uv_loop_, platform,nullptr,nullptr,
617-
static_cast<node::IsolateDataFlags::Flags>(isolate_data_flags));
607+
auto* isolate_data =node::CreateIsolateData(isolate, uv_loop_, platform);
618608
context->SetAlignedPointerInEmbedderData(kElectronContextEmbedderDataIndex,
619609
static_cast<void*>(isolate_data));
620610

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp