Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable freezing V8 flags on initialization #141

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,11 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
// used in diagnostic reports.
per_process::cli_options->cmdline = *argv;

// Node provides a "v8.setFlagsFromString" method to dynamically change flags.
// Hence do not freeze flags when initializing V8. In a browser setting, this
// is security relevant, for Node it's less important.
V8::SetFlagsFromString("--no-freeze-flags-after-init");

#if defined(NODE_V8_OPTIONS)
// Should come before the call to V8::SetFlagsFromCommandLine()
// so the user can disable a flag --foo at run-time by passing
Expand Down
5 changes: 5 additions & 0 deletions test/cctest/node_test_fixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ void NodeTestEnvironment::SetUp() {
#endif
cppgc::InitializeProcess(
NodeZeroIsolateTestFixture::platform->GetPageAllocator());

// Before initializing V8, disable the --freeze-flags-after-init flag, so
// individual tests can set their own flags.
v8::V8::SetFlagsFromString("--no-freeze-flags-after-init");

v8::V8::Initialize();
}

Expand Down
2 changes: 2 additions & 0 deletions tools/code_cache/mkcodecache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ int main(int argc, char* argv[]) {

v8::V8::SetFlagsFromString("--random_seed=42");
v8::V8::SetFlagsFromString("--harmony-import-assertions");
// Do not freeze flags so we can later reset the random seed.
v8::V8::SetFlagsFromString("--no-freeze-flags-after-init");

if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <path/to/output.cc>\n";
Expand Down