Skip to content
Permalink
Browse files

src: keep main-thread Isolate attached to platform during Dispose

This works around a situation in which the V8 WASM code calls
into the platform while the Isolate is being disposed.

This goes against the V8 API constract for `v8::Platform`.
In lieu of a proper fix, it should be okay to keep the Isolate
registered; the race condition fixed by 25447d8 cannot
occur for the `NodeMainInstance`’s Isolate, as it is the last
one to exit in any given Node.js process.

This partially reverts 25447d8.

Refs: #30909
Refs: #31752

PR-URL: #31795
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax committed Feb 14, 2020
1 parent f0b2d87 commit 43d02e20e0f37c3494cdf950fb9586f911df3d39
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/node_main_instance.cc
@@ -99,8 +99,12 @@ NodeMainInstance::~NodeMainInstance() {
if (!owns_isolate_) {
return;
}
platform_->UnregisterIsolate(isolate_);
// TODO(addaleax): Reverse the order of these calls. The fact that we first
// dispose the Isolate is a temporary workaround for
// https://github.com/nodejs/node/issues/31752 -- V8 should not be posting
// platform tasks during Dispose(), but it does in some WASM edge cases.
isolate_->Dispose();
platform_->UnregisterIsolate(isolate_);
}

int NodeMainInstance::Run() {

0 comments on commit 43d02e2

Please sign in to comment.
You can’t perform that action at this time.