Index: runtime/vm/gc_sweeper.cc |
diff --git a/runtime/vm/gc_sweeper.cc b/runtime/vm/gc_sweeper.cc |
index 2b4ee58222014150a74493011907008f39c7a3e1..4cd224377b14c6ad084004ff16f48e6a541c358c 100644 |
--- a/runtime/vm/gc_sweeper.cc |
+++ b/runtime/vm/gc_sweeper.cc |
@@ -137,13 +137,14 @@ class SweeperTask : public ThreadPool::Task { |
if (page == last_) break; |
page = next_page; |
} |
+ // Exit isolate cleanly *before* notifying it, to avoid shutdown race. |
+ Thread::ExitIsolateAsHelper(); |
// This sweeper task is done. Notify the original isolate. |
{ |
MonitorLocker ml(old_space_->tasks_lock()); |
old_space_->set_tasks(old_space_->tasks() - 1); |
ml.Notify(); |
} |
- Thread::ExitIsolateAsHelper(); |
} |
private: |