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 cf25a5e

Browse filesBrowse files
legendecasmarco-ippolito
authored andcommitted
src: drain platform tasks before creating startup snapshot
Drain the loop and platform tasks before creating a snapshot. This is necessary to ensure that the no roots are held by the the platform tasks, which may reference objects associated with a context. For example, a WeakRef may schedule an per-isolate platform task as a GC root, and referencing an object in a context, causing an assertion in the snapshot creator. PR-URL: #56403 Refs: #56292 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 597a39b commit cf25a5e
Copy full SHA for cf25a5e

File tree

Expand file treeCollapse file tree

1 file changed

+14
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-10
lines changed
Open diff view settings
Collapse file

‎src/node_snapshotable.cc‎

Copy file name to clipboardExpand all lines: src/node_snapshotable.cc
+14-10Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -993,25 +993,29 @@ ExitCode BuildSnapshotWithoutCodeCache(
993993
}
994994
});
995995

996+
Context::Scope context_scope(setup->context());
997+
Environment* env = setup->env();
998+
996999
// Run the custom main script for fully customized snapshots.
9971000
if (snapshot_type == SnapshotMetadata::Type::kFullyCustomized) {
998-
Context::Scope context_scope(setup->context());
999-
Environment* env = setup->env();
10001001
#if HAVE_INSPECTOR
10011002
env->InitializeInspector({});
10021003
#endif
10031004
if (LoadEnvironment(env, builder_script_content.value()).IsEmpty()) {
10041005
return ExitCode::kGenericUserError;
10051006
}
1007+
}
10061008

1007-
// FIXME(joyeecheung): right now running the loop in the snapshot
1008-
// builder might introduce inconsistencies in JS land that need to
1009-
// be synchronized again after snapshot restoration.
1010-
ExitCode exit_code =
1011-
SpinEventLoopInternal(env).FromMaybe(ExitCode::kGenericUserError);
1012-
if (exit_code != ExitCode::kNoFailure) {
1013-
return exit_code;
1014-
}
1009+
// Drain the loop and platform tasks before creating a snapshot. This is
1010+
// necessary to ensure that the no roots are held by the the platform
1011+
// tasks, which may reference objects associated with a context. For
1012+
// example, a WeakRef may schedule an per-isolate platform task as a GC
1013+
// root, and referencing an object in a context, causing an assertion in
1014+
// the snapshot creator.
1015+
ExitCode exit_code =
1016+
SpinEventLoopInternal(env).FromMaybe(ExitCode::kGenericUserError);
1017+
if (exit_code != ExitCode::kNoFailure) {
1018+
return exit_code;
10151019
}
10161020
}
10171021

0 commit comments

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