Skip to content

Commit c8b2a11

Browse files
backespthier
authored and
pthier
committed
Disable freezing V8 flags on initialization (#141)
Node still changes flags after initializationg; either because tests need to set their own flags (which V8 tests also still allow), or because it's explicitly requested via the "v8.setFlagsFromString" method that Node provides.
1 parent d4ce247 commit c8b2a11

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/node.cc

+5
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,11 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
738738
// used in diagnostic reports.
739739
per_process::cli_options->cmdline = *argv;
740740

741+
// Node provides a "v8.setFlagsFromString" method to dynamically change flags.
742+
// Hence do not freeze flags when initializing V8. In a browser setting, this
743+
// is security relevant, for Node it's less important.
744+
V8::SetFlagsFromString("--no-freeze-flags-after-init");
745+
741746
#if defined(NODE_V8_OPTIONS)
742747
// Should come before the call to V8::SetFlagsFromCommandLine()
743748
// so the user can disable a flag --foo at run-time by passing

test/cctest/node_test_fixture.cc

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ void NodeTestEnvironment::SetUp() {
2424
#endif
2525
cppgc::InitializeProcess(
2626
NodeZeroIsolateTestFixture::platform->GetPageAllocator());
27+
28+
// Before initializing V8, disable the --freeze-flags-after-init flag, so
29+
// individual tests can set their own flags.
30+
v8::V8::SetFlagsFromString("--no-freeze-flags-after-init");
31+
2732
v8::V8::Initialize();
2833
}
2934

0 commit comments

Comments
 (0)