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 ace3e70

Browse filesBrowse files
addaleaxtargos
authored andcommitted
src: unregister Isolate with platform before disposing
I previously thought the order of these calls was no longer relevant. I was wrong. This commit undoes the changes from 312c02d, adds a comment explaining why I was wrong, and flips the order of the calls elsewhere for consistency, the latter having been the goal of 312c02d. Fixes: #30846 Refs: #30181 PR-URL: #30909 Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 8cd8cd7 commit ace3e70
Copy full SHA for ace3e70

File tree

Expand file treeCollapse file tree

4 files changed

+9
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+9
-3
lines changed
Open diff view settings
Collapse file

‎src/node.h‎

Copy file name to clipboardExpand all lines: src/node.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform {
280280

281281
// This function may only be called once per `Isolate`, and discard any
282282
// pending delayed tasks scheduled for that isolate.
283+
// This needs to be called right before calling `Isolate::Dispose()`.
283284
virtual void UnregisterIsolate(v8::Isolate* isolate) = 0;
284285

285286
// The platform should call the passed function once all state associated
Collapse file

‎src/node_main_instance.cc‎

Copy file name to clipboardExpand all lines: src/node_main_instance.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ NodeMainInstance::~NodeMainInstance() {
9999
if (!owns_isolate_) {
100100
return;
101101
}
102-
isolate_->Dispose();
103102
platform_->UnregisterIsolate(isolate_);
103+
isolate_->Dispose();
104104
}
105105

106106
int NodeMainInstance::Run() {
Collapse file

‎src/node_worker.cc‎

Copy file name to clipboardExpand all lines: src/node_worker.cc
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,13 @@ class WorkerThreadData {
192192
*static_cast<bool*>(data) = true;
193193
}, &platform_finished);
194194

195-
isolate->Dispose();
195+
// The order of these calls is important; if the Isolate is first disposed
196+
// and then unregistered, there is a race condition window in which no
197+
// new Isolate at the same address can successfully be registered with
198+
// the platform.
199+
// (Refs: https://github.com/nodejs/node/issues/30846)
196200
w_->platform_->UnregisterIsolate(isolate);
201+
isolate->Dispose();
197202

198203
// Wait until the platform has cleaned up all relevant resources.
199204
while (!platform_finished)
Collapse file

‎test/cctest/node_test_fixture.h‎

Copy file name to clipboardExpand all lines: test/cctest/node_test_fixture.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ class NodeTestFixture : public ::testing::Test {
106106

107107
void TearDown() override {
108108
isolate_->Exit();
109-
isolate_->Dispose();
110109
platform->DrainTasks(isolate_);
111110
platform->UnregisterIsolate(isolate_);
111+
isolate_->Dispose();
112112
isolate_ = nullptr;
113113
}
114114
};

0 commit comments

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