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 5f51729

Browse filesBrowse files
joyeecheungdanielleadams
authored andcommitted
bootstrap: move event loop handle checking into snapshot builder
This is only necessary for the snapshot builder (because we have no way to resurrect the handles at the moment). In addition, print the handles if the debug flag is set or if the queues are not empty after snapshot is created. PR-URL: #39007 Refs: #35711 Refs: #38905 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 9d100aa commit 5f51729
Copy full SHA for 5f51729

File tree

Expand file treeCollapse file tree

2 files changed

+15
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-2
lines changed
Open diff view settings
Collapse file

‎src/node_main_instance.cc‎

Copy file name to clipboardExpand all lines: src/node_main_instance.cc
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ NodeMainInstance::CreateMainEnvironment(int* exit_code,
224224
}
225225
}
226226

227-
CHECK(env->req_wrap_queue()->IsEmpty());
228-
CHECK(env->handle_wrap_queue()->IsEmpty());
229227
return env;
230228
}
231229

Collapse file

‎src/node_snapshotable.cc‎

Copy file name to clipboardExpand all lines: src/node_snapshotable.cc
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,22 @@ void SnapshotBuilder::Generate(SnapshotData* out,
157157
// Must be out of HandleScope
158158
out->blob =
159159
creator.CreateBlob(SnapshotCreator::FunctionCodeHandling::kClear);
160+
161+
// We must be able to rehash the blob when we restore it or otherwise
162+
// the hash seed would be fixed by V8, introducing a vulnerability.
160163
CHECK(out->blob.CanBeRehashed());
164+
165+
// We cannot resurrect the handles from the snapshot, so make sure that
166+
// no handles are left open in the environment after the blob is created
167+
// (which should trigger a GC and close all handles that can be closed).
168+
if (!env->req_wrap_queue()->IsEmpty()
169+
|| !env->handle_wrap_queue()->IsEmpty()
170+
|| per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) {
171+
PrintLibuvHandleInformation(env->event_loop(), stderr);
172+
}
173+
CHECK(env->req_wrap_queue()->IsEmpty());
174+
CHECK(env->handle_wrap_queue()->IsEmpty());
175+
161176
// Must be done while the snapshot creator isolate is entered i.e. the
162177
// creator is still alive.
163178
FreeEnvironment(env);

0 commit comments

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