Skip to content

Commit fa26f83

Browse files
joyeecheungtargos
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 <legendecas@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent b50fc42 commit fa26f83

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/env.cc

+1
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ IsolateData::IsolateData(Isolate* isolate,
615615

616616
IsolateData::~IsolateData() {
617617
if (cpp_heap_ != nullptr) {
618+
v8::Locker locker(isolate_);
618619
// The CppHeap must be detached before being terminated.
619620
isolate_->DetachCppHeap();
620621
cpp_heap_->Terminate();

test/cctest/test_environment.cc

+3
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

+1
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)