diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2021-06-11 16:02:50 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2021-06-21 17:04:13 +0300 |
commit | f8898eae67630be7abc615b352e7c7b26e265c4f (patch) | |
tree | f93b483622a2c29095f0c8de8533053b16f9f3a8 /src/node_snapshotable.cc | |
parent | 44c598158c8a135e0faf901b590689428398f4d5 (diff) |
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: https://github.com/nodejs/node/pull/39007
Refs: https://github.com/nodejs/node/issues/35711
Refs: https://github.com/nodejs/node/pull/38905
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_snapshotable.cc')
-rw-r--r-- | src/node_snapshotable.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index 1871cef443f..35e0ed3f6df 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -157,7 +157,22 @@ void SnapshotBuilder::Generate(SnapshotData* out, // Must be out of HandleScope out->blob = creator.CreateBlob(SnapshotCreator::FunctionCodeHandling::kClear); + + // We must be able to rehash the blob when we restore it or otherwise + // the hash seed would be fixed by V8, introducing a vulnerability. CHECK(out->blob.CanBeRehashed()); + + // We cannot resurrect the handles from the snapshot, so make sure that + // no handles are left open in the environment after the blob is created + // (which should trigger a GC and close all handles that can be closed). + if (!env->req_wrap_queue()->IsEmpty() + || !env->handle_wrap_queue()->IsEmpty() + || per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) { + PrintLibuvHandleInformation(env->event_loop(), stderr); + } + CHECK(env->req_wrap_queue()->IsEmpty()); + CHECK(env->handle_wrap_queue()->IsEmpty()); + // Must be done while the snapshot creator isolate is entered i.e. the // creator is still alive. FreeEnvironment(env); |