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

Appearance settings

Commit fcc4bf9

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
deps: V8: cherry-pick ca5b0ec
Original commit message: [heap] Ensure SyntheticModule is initialized before next allocation Ensure that all fields of `SyntheticModule` are set before creating the exports hash table for it, because the latter may trigger garbage collection, leading to crashes. This has been causing failures in the Node.js CI over the last weeks, after making the creating of synthetic modules part of Node’s startup sequence. (I am generally not very familiar with this part of the V8 code and there might be a better way, or possibly a way to add a reliable regression test, that I am not aware of.) Refs: #30498 Refs: #30648 Change-Id: I32da4b7bd888c6ec1421f34f5bd52e7bad154c1e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1939752 Commit-Queue: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#65247} Refs: https://github.com/v8/v8/commit/ \ ca5b0ec2722d2af4551c01ca78921fa16a26ae72 Fixes: #30498 Fixes: #30648 PR-URL: #30708 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent eb4b932 commit fcc4bf9
Copy full SHA for fcc4bf9

File tree

Expand file treeCollapse file tree

3 files changed

+32
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+32
-5
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.23',
41+
'v8_embedder_string': '-node.24',
4242

4343
##### V8 defaults for Node.js #####
4444

Collapse file

‎deps/v8/src/heap/factory.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/heap/factory.cc
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,20 +3068,22 @@ Handle<SyntheticModule> Factory::NewSyntheticModule(
30683068
Handle<String> module_name, Handle<FixedArray> export_names,
30693069
v8::Module::SyntheticModuleEvaluationSteps evaluation_steps) {
30703070
ReadOnlyRoots roots(isolate());
3071-
Handle<SyntheticModule> module(
3072-
SyntheticModule::cast(New(synthetic_module_map(), AllocationType::kOld)),
3073-
isolate());
3071+
30743072
Handle<ObjectHashTable> exports =
30753073
ObjectHashTable::New(isolate(), static_cast<int>(export_names->length()));
30763074
Handle<Foreign> evaluation_steps_foreign =
30773075
NewForeign(reinterpret_cast<i::Address>(evaluation_steps));
3078-
module->set_exports(*exports);
3076+
3077+
Handle<SyntheticModule> module(
3078+
SyntheticModule::cast(New(synthetic_module_map(), AllocationType::kOld)),
3079+
isolate());
30793080
module->set_hash(isolate()->GenerateIdentityHash(Smi::kMaxValue));
30803081
module->set_module_namespace(roots.undefined_value());
30813082
module->set_status(Module::kUninstantiated);
30823083
module->set_exception(roots.the_hole_value());
30833084
module->set_name(*module_name);
30843085
module->set_export_names(*export_names);
3086+
module->set_exports(*exports);
30853087
module->set_evaluation_steps(*evaluation_steps_foreign);
30863088
return module;
30873089
}
Collapse file

‎deps/v8/test/cctest/test-api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-api.cc
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23874,6 +23874,31 @@ TEST(CreateSyntheticModule) {
2387423874
CHECK_EQ(i_module->status(), i::Module::kInstantiated);
2387523875
}
2387623876

23877+
TEST(CreateSyntheticModuleGC) {
23878+
// Try to make sure that CreateSyntheticModule() deals well with a GC
23879+
// happening during its execution.
23880+
i::FLAG_gc_interval = 10;
23881+
i::FLAG_inline_new = false;
23882+
23883+
LocalContext env;
23884+
v8::Isolate* isolate = env->GetIsolate();
23885+
v8::Isolate::Scope iscope(isolate);
23886+
v8::HandleScope scope(isolate);
23887+
v8::Local<v8::Context> context = v8::Context::New(isolate);
23888+
v8::Context::Scope cscope(context);
23889+
23890+
std::vector<v8::Local<v8::String>> export_names{v8_str("default")};
23891+
v8::Local<v8::String> module_name =
23892+
v8_str("CreateSyntheticModule-TestSyntheticModuleGC");
23893+
23894+
for (int i = 0; i < 200; i++) {
23895+
Local<Module> module = v8::Module::CreateSyntheticModule(
23896+
isolate, module_name, export_names,
23897+
UnexpectedSyntheticModuleEvaluationStepsCallback);
23898+
USE(module);
23899+
}
23900+
}
23901+
2387723902
TEST(SyntheticModuleSetExports) {
2387823903
LocalContext env;
2387923904
v8::Isolate* isolate = env->GetIsolate();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.