diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index 1e83681dd58a..a240829b85f6 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -1808,15 +1808,17 @@ static MessageHandler::MessageStatus RunIsolate(uword parameter) { static void ShutdownIsolate(uword parameter) { Isolate* isolate = reinterpret_cast(parameter); - // We must wait for any outstanding spawn calls to complete before - // running the shutdown callback. - isolate->WaitForOutstandingSpawns(); { // Print the error if there is one. This may execute dart code to // print the exception object, so we need to use a StartIsolateScope. StartIsolateScope start_scope(isolate); Thread* thread = Thread::Current(); ASSERT(thread->isolate() == isolate); + + // We must wait for any outstanding spawn calls to complete before + // running the shutdown callback. + isolate->WaitForOutstandingSpawns(); + StackZone zone(thread); HandleScope handle_scope(thread); #if defined(DEBUG) @@ -2998,9 +3000,11 @@ void Isolate::DecrementSpawnCount() { } void Isolate::WaitForOutstandingSpawns() { + Thread* thread = Thread::Current(); + ASSERT(thread != NULL); MonitorLocker ml(&spawn_count_monitor_); while (spawn_count_ > 0) { - ml.Wait(); + ml.WaitWithSafepointCheck(thread); } } diff --git a/runtime/vm/kernel_isolate.cc b/runtime/vm/kernel_isolate.cc index fdd0e4aaf6f4..72b9ec3c4b07 100644 --- a/runtime/vm/kernel_isolate.cc +++ b/runtime/vm/kernel_isolate.cc @@ -134,7 +134,6 @@ class RunKernelTask : public ThreadPool::Task { OS::PrintErr(DART_KERNEL_ISOLATE_NAME ": ShutdownIsolate\n"); } Isolate* I = reinterpret_cast(parameter); - I->WaitForOutstandingSpawns(); { // Print the error if there is one. This may execute dart code to // print the exception object, so we need to use a StartIsolateScope. @@ -142,6 +141,7 @@ class RunKernelTask : public ThreadPool::Task { StartIsolateScope start_scope(I); Thread* T = Thread::Current(); ASSERT(I == T->isolate()); + I->WaitForOutstandingSpawns(); StackZone zone(T); HandleScope handle_scope(T); Error& error = Error::Handle(Z); diff --git a/runtime/vm/service_isolate.cc b/runtime/vm/service_isolate.cc index 3d64580564be..f0805491f873 100644 --- a/runtime/vm/service_isolate.cc +++ b/runtime/vm/service_isolate.cc @@ -381,7 +381,6 @@ class RunServiceTask : public ThreadPool::Task { } Isolate* I = reinterpret_cast(parameter); ASSERT(ServiceIsolate::IsServiceIsolate(I)); - I->WaitForOutstandingSpawns(); { // Print the error if there is one. This may execute dart code to // print the exception object, so we need to use a StartIsolateScope. @@ -389,6 +388,7 @@ class RunServiceTask : public ThreadPool::Task { StartIsolateScope start_scope(I); Thread* T = Thread::Current(); ASSERT(I == T->isolate()); + I->WaitForOutstandingSpawns(); StackZone zone(T); HandleScope handle_scope(T); Error& error = Error::Handle(Z); diff --git a/tests/co19_2/co19_2-kernel.status b/tests/co19_2/co19_2-kernel.status index 5bbfa57cbfb7..e074d1d8ca57 100644 --- a/tests/co19_2/co19_2-kernel.status +++ b/tests/co19_2/co19_2-kernel.status @@ -9,10 +9,6 @@ LanguageFeatures/Set-literals/syntax_compatibility_A01_t02: RuntimeError LibTest/isolate/Isolate/kill_A01_t01: Skip # Issue 37699 LibTest/isolate/Isolate/pause_A01_t01: Skip # Issue 37699 LibTest/isolate/Isolate/pause_A01_t02: Skip # Issue 37699 -LibTest/isolate/ReceivePort/firstWhere_A01_t01: Skip # Issue 37679 -LibTest/isolate/ReceivePort/firstWhere_A02_t01: Skip # Issue 37679 -LibTest/isolate/ReceivePort/transform_A01_t01: Skip # Issue 37679 -LibTest/isolate/ReceivePort/transform_A01_t02: Skip # Issue 37679 [ $compiler == dartkp ] Language/Expressions/Instance_Creation/New/evaluation_t20: RuntimeError