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

Unified Diff: runtime/vm/isolate.cc

Issue 2191723002: Fix race condition with HasMutatorThread that was being used without a lock. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address self review comments. Created 4 years, 5 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
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 697aef86d87c8180253e0a3e2dff0e2ce41d9520..15091b58d9cc77c515c731d5ca412274ab46d407 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -989,6 +989,12 @@ Isolate* Isolate::Init(const char* name_prefix,
}
+Thread* Isolate::mutator_thread() const {
+ ASSERT(thread_registry() != NULL);
+ return thread_registry()->mutator_thread();
+}
+
+
void Isolate::SetupInstructionsSnapshotPage(
const uint8_t* instructions_snapshot_buffer) {
InstructionsSnapshot snapshot(instructions_snapshot_buffer);
@@ -2585,6 +2591,11 @@ Thread* Isolate::ScheduleThread(bool is_mutator, bool bypass_safepoint) {
// no_safepoint_scope_depth increments/decrements.
MonitorLocker ml(threads_lock(), false);
+ // Check to make sure we don't already have a mutator thread.
+ if (is_mutator && mutator_thread_ != NULL) {
+ return NULL;
+ }
+
// If a safepoint operation is in progress wait for it
// to finish before scheduling this thread in.
while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) {
« runtime/vm/isolate.h ('K') | « runtime/vm/isolate.h ('k') | runtime/vm/thread_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698