Fix a race condition during the rosalloc verification.
Since an exiting thread could revoke its thread-local runs without
holding the mutator lock, when rosalloc verification is running at a
pause, the thread could concurrently modify runs and cause a race
condition/verification check failure.
Now an exiting thread acquires the mutator lock when it revokes its
thread-local runs, which should avoid the race condition.
Bug: 18734151
Bug: 18577084
Change-Id: Ic8af558b96dff6fb6f5ace65351e2824a6ff4629
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 2308cc9..4a7103b 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1210,7 +1210,10 @@
tlsPtr_.opeer = nullptr;
}
- Runtime::Current()->GetHeap()->RevokeThreadLocalBuffers(this);
+ {
+ ScopedObjectAccess soa(self);
+ Runtime::Current()->GetHeap()->RevokeThreadLocalBuffers(this);
+ }
}
Thread::~Thread() {