Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: runtime/vm/dart.cc

Issue 2052343002: Fix dead lock in isolate shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add check for service isolate running Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart.cc
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index fe8154ba764df85f7f94087b1ea3eb2a43438ceb..93cac99fa76ff155414d44647bf486c0a2c2066d 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -310,6 +310,24 @@ char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
}
+// This waits until only the VM isolate and the service isolate remains in the
+// list, i.e. list length == 2.
+void Dart::WaitForApplicationIsolateShutdown() {
+ ASSERT(!Isolate::creation_enabled_);
+ MonitorLocker ml(Isolate::isolates_list_monitor_);
+ while ((Isolate::isolates_list_head_ != NULL) &&
+ (Isolate::isolates_list_head_->next_ != NULL) &&
+ (Isolate::isolates_list_head_->next_->next_ != NULL)) {
+ ml.Wait();
+ }
+ ASSERT(
+ ((Isolate::isolates_list_head_ == Dart::vm_isolate()) &&
+ ServiceIsolate::IsServiceIsolate(Isolate::isolates_list_head_->next_)) ||
+ ((Isolate::isolates_list_head_->next_ == Dart::vm_isolate()) &&
+ ServiceIsolate::IsServiceIsolate(Isolate::isolates_list_head_)));
+}
+
+
// This waits until only the VM isolate remains in the list.
void Dart::WaitForIsolateShutdown() {
ASSERT(!Isolate::creation_enabled_);
@@ -371,6 +389,16 @@ const char* Dart::Cleanup() {
}
Isolate::KillAllIsolates(Isolate::kInternalKillMsg);
+ // Wait for all isolates, but the service and the vm isolate to shut down.
+ // Only do that if there is a service isolate running.
+ if (ServiceIsolate::IsRunning()) {
+ if (FLAG_trace_shutdown) {
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down app isolates\n",
+ timestamp());
+ }
+ WaitForApplicationIsolateShutdown();
+ }
+
// Shutdown the service isolate.
if (FLAG_trace_shutdown) {
OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n",
@@ -378,7 +406,7 @@ const char* Dart::Cleanup() {
}
ServiceIsolate::Shutdown();
- // Wait for all application isolates and the service isolate to shutdown
+ // Wait for the remaining isolate (service isolate) to shutdown
// before shutting down the thread pool.
if (FLAG_trace_shutdown) {
OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Waiting for isolate shutdown\n",
« no previous file with comments | « runtime/vm/dart.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698