Skip to content

Commit 619e52c

Browse files
joyeecheungRafaelGSS
authored andcommitted
src: lock the isolate properly in IsolateData destructor
Otherwise it may fail the DCHECK that uses the locked thread as a fast path to get the current thread. PR-URL: #57031 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 44b19ec commit 619e52c

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/env.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ IsolateData::IsolateData(Isolate* isolate,
619619

620620
IsolateData::~IsolateData() {
621621
if (cpp_heap_ != nullptr) {
622+
v8::Locker locker(isolate_);
622623
// The CppHeap must be detached before being terminated.
623624
isolate_->DetachCppHeap();
624625
cpp_heap_->Terminate();

test/cctest/test_environment.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ TEST_F(EnvironmentTest, InspectorMultipleEmbeddedEnvironments) {
438438
// This test sets a global variable in the child Environment, and reads it
439439
// back both through the inspector and inside the child Environment, and
440440
// makes sure that those correspond to the value that was originally set.
441+
v8::Locker locker(isolate_);
441442
const v8::HandleScope handle_scope(isolate_);
442443
const Argv argv;
443444
Env env {handle_scope, argv};
@@ -507,6 +508,7 @@ TEST_F(EnvironmentTest, InspectorMultipleEmbeddedEnvironments) {
507508
CHECK_NOT_NULL(isolate);
508509

509510
{
511+
v8::Locker locker(isolate);
510512
v8::Isolate::Scope isolate_scope(isolate);
511513
v8::HandleScope handle_scope(isolate);
512514

@@ -630,6 +632,7 @@ TEST_F(NodeZeroIsolateTestFixture, CtrlCWithOnlySafeTerminationTest) {
630632

631633
// Try creating Context + IsolateData + Environment.
632634
{
635+
v8::Locker locker(isolate);
633636
v8::Isolate::Scope isolate_scope(isolate);
634637
v8::HandleScope handle_scope(isolate);
635638

test/cctest/test_platform.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ TEST_F(NodeZeroIsolateTestFixture, IsolatePlatformDelegateTest) {
7676

7777
// Try creating Context + IsolateData + Environment
7878
{
79+
v8::Locker locker(isolate);
7980
v8::Isolate::Scope isolate_scope(isolate);
8081
v8::HandleScope handle_scope(isolate);
8182

0 commit comments

Comments
 (0)