Skip to content

Commit 0d97b9c

Browse files
gahaaspthier
authored andcommitted
Unregister isolate after Isolate::Dispose (#208)
During Isolate::Dispose, CppHeap sweeping gets started, which tries to load a ForegroundTaskRunner. Loading the ForegroundTaskRunner is, however, not possible anymore after NodePlatform::UnregisterIsolate.
1 parent ddd0be4 commit 0d97b9c

File tree

10 files changed

+11
-11
lines changed

10 files changed

+11
-11
lines changed

src/heap_utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class JSGraph : public EmbedderGraph {
8989
}
9090

9191
Node* V8Node(const Local<v8::Value>& value) override {
92-
return V8Node(value.As<v8::Data>());
92+
return V8Node(Local<v8::Data>(value));
9393
}
9494

9595
Node* AddNode(std::unique_ptr<Node> node) override {

src/node_main_instance.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ NodeMainInstance::~NodeMainInstance() {
8181
// This should only be done on a main instance that owns its isolate.
8282
// IsolateData must be freed before UnregisterIsolate() is called.
8383
isolate_data_.reset();
84-
platform_->UnregisterIsolate(isolate_);
8584
}
8685
isolate_->Dispose();
86+
platform_->UnregisterIsolate(isolate_);
8787
}
8888

8989
ExitCode NodeMainInstance::Run() {

src/node_worker.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ class WorkerThreadData {
235235
// new Isolate at the same address can successfully be registered with
236236
// the platform.
237237
// (Refs: https://github.com/nodejs/node/issues/30846)
238-
w_->platform_->UnregisterIsolate(isolate);
239238
isolate->Dispose();
239+
w_->platform_->UnregisterIsolate(isolate);
240240

241241
// Wait until the platform has cleaned up all relevant resources.
242242
while (!platform_finished) {

src/util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ RAIIIsolateWithoutEntering::RAIIIsolateWithoutEntering(const SnapshotData* data)
730730
}
731731

732732
RAIIIsolateWithoutEntering::~RAIIIsolateWithoutEntering() {
733-
per_process::v8_platform.Platform()->UnregisterIsolate(isolate_);
734733
isolate_->Dispose();
734+
per_process::v8_platform.Platform()->UnregisterIsolate(isolate_);
735735
}
736736

737737
RAIIIsolate::RAIIIsolate(const SnapshotData* data)

test/cctest/node_test_fixture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class NodeTestFixture : public NodeZeroIsolateTestFixture {
123123
void TearDown() override {
124124
platform->DrainTasks(isolate_);
125125
isolate_->Exit();
126-
platform->UnregisterIsolate(isolate_);
127126
isolate_->Dispose();
127+
platform->UnregisterIsolate(isolate_);
128128
isolate_ = nullptr;
129129
NodeZeroIsolateTestFixture::TearDown();
130130
}

test/cctest/test_cppgc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ TEST_F(NodeZeroIsolateTestFixture, ExistingCppHeapTest) {
107107
platform->DrainTasks(isolate);
108108
}
109109

110-
platform->UnregisterIsolate(isolate);
111110
isolate->Dispose();
111+
platform->UnregisterIsolate(isolate);
112112

113113
// Check that all the objects are created and destroyed properly.
114114
EXPECT_EQ(CppGCed::kConstructCount, 100);

test/cctest/test_environment.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ TEST_F(EnvironmentTest, InspectorMultipleEmbeddedEnvironments) {
545545
node::FreeIsolateData(isolate_data);
546546
}
547547

548-
data->platform->UnregisterIsolate(isolate);
549548
isolate->Dispose();
549+
data->platform->UnregisterIsolate(isolate);
550550
uv_run(&loop, UV_RUN_DEFAULT);
551551
CHECK_EQ(uv_loop_close(&loop), 0);
552552

@@ -676,8 +676,8 @@ TEST_F(NodeZeroIsolateTestFixture, CtrlCWithOnlySafeTerminationTest) {
676676
}
677677

678678
// Cleanup.
679-
platform->UnregisterIsolate(isolate);
680679
isolate->Dispose();
680+
platform->UnregisterIsolate(isolate);
681681
}
682682
#endif // _WIN32
683683

test/cctest/test_platform.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ TEST_F(NodeZeroIsolateTestFixture, IsolatePlatformDelegateTest) {
104104

105105
// Graceful shutdown
106106
delegate->Shutdown();
107-
platform->UnregisterIsolate(isolate);
108107
isolate->Dispose();
108+
platform->UnregisterIsolate(isolate);
109109
}
110110

111111
TEST_F(PlatformTest, TracingControllerNullptr) {

test/fuzzers/fuzz_env.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class FuzzerFixtureHelper {
6565
void Teardown() {
6666
platform->DrainTasks(isolate_);
6767
isolate_->Exit();
68-
platform->UnregisterIsolate(isolate_);
6968
isolate_->Dispose();
69+
platform->UnregisterIsolate(isolate_);
7070
isolate_ = nullptr;
7171
}
7272
};

test/fuzzers/fuzz_strings.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ class FuzzerFixtureHelper {
7272
void Teardown() {
7373
platform->DrainTasks(isolate_);
7474
isolate_->Exit();
75-
platform->UnregisterIsolate(isolate_);
7675
isolate_->Dispose();
76+
platform->UnregisterIsolate(isolate_);
7777
isolate_ = nullptr;
7878
}
7979
};

0 commit comments

Comments
 (0)