Skip to content

Commit 2e49b99

Browse files
backestargos
authored andcommitted
src,test: disable freezing V8 flags on initialization
Node.js 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.js provides. PR-URL: #44741 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent fd52c62 commit 2e49b99

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
@@ -741,6 +741,11 @@ static ExitCode InitializeNodeWithArgsInternal(
741741
// used in diagnostic reports.
742742
per_process::cli_options->cmdline = *argv;
743743

744+
// Node provides a "v8.setFlagsFromString" method to dynamically change flags.
745+
// Hence do not freeze flags when initializing V8. In a browser setting, this
746+
// is security relevant, for Node it's less important.
747+
V8::SetFlagsFromString("--no-freeze-flags-after-init");
748+
744749
#if defined(NODE_V8_OPTIONS)
745750
// Should come before the call to V8::SetFlagsFromCommandLine()
746751
// 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)