From 258487cafdfee1ef9d04ca8caf0fc3c09ef6dda4 Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Tue, 7 Sep 2021 14:08:32 +0000 Subject: [PATCH] [vm] If isolate group spawning fails, we need to enter the IG in order to delete the api state Fixes https://github.com/dart-lang/sdk/issues/47087 TEST=Fixes vm/dart_2/spawn_shutdown_test/1 test failure. Change-Id: I416c4732d71eed9fe6fb26b8a5ce12ed5b122d4d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212584 Commit-Queue: Martin Kustermann Auto-Submit: Martin Kustermann Reviewed-by: Daco Harkes --- runtime/lib/isolate.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc index 5dfb8b80c8e..0af5e7635cb 100644 --- a/runtime/lib/isolate.cc +++ b/runtime/lib/isolate.cc @@ -655,7 +655,7 @@ class SpawnIsolateTask : public ThreadPool::Task { parent_isolate_ = nullptr; if (isolate == nullptr) { - FailedSpawn(error); + FailedSpawn(error, /*has_current_isolate=*/false); free(error); return; } @@ -681,7 +681,7 @@ class SpawnIsolateTask : public ThreadPool::Task { parent_isolate_ = nullptr; if (isolate == nullptr) { - FailedSpawn(error, false); + FailedSpawn(error, /*has_current_isolate=*/false); free(error); return; } @@ -854,7 +854,7 @@ class SpawnIsolateTask : public ThreadPool::Task { if (has_current_isolate) { ASSERT(IsolateGroup::Current() == state_->isolate_group()); state_ = nullptr; - } else { + } else if (state_->isolate_group() != nullptr) { ASSERT(IsolateGroup::Current() == nullptr); const bool kBypassSafepoint = false; const bool result = Thread::EnterIsolateGroupAsHelper( @@ -862,6 +862,10 @@ class SpawnIsolateTask : public ThreadPool::Task { ASSERT(result); state_ = nullptr; Thread::ExitIsolateGroupAsHelper(kBypassSafepoint); + } else { + // The state won't need a current isolate group, because it belongs to a + // [Isolate.spawnUri] call. + state_ = nullptr; } }