summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2013-12-03 14:24:05 -0800
committerMathieu Chartier <mathieuc@google.com>2013-12-05 12:57:43 -0800
commit5f51d4b80058236759fea1d932470a57f348c199 (patch)
tree096ce11ba8dc096fd27d2fbed84459080c7d3b1e /runtime/monitor.cc
parentd83d4c86c89357a74e94963994ad0c42ea7299c3 (diff)
downloadart-5f51d4b80058236759fea1d932470a57f348c199.tar.gz
art-5f51d4b80058236759fea1d932470a57f348c199.tar.bz2
art-5f51d4b80058236759fea1d932470a57f348c199.zip
Fix races in thread list Unregister.
First race: We were releasing the thin_lock_id in Unregister before the thread was not suspended. This could cause problems in SuspendThreadByThreadId since there was a small window of time where two threads could share the same thread id. This race caused an occasional check failure in SuspendThreadByThreadId. Second race: We were setting the thin_lock_thread_id_ to 0 in Unregister before waiting to not be suspended. This caused another race in SuspendThreadByThreadId where we modified the thread suspend count, busy waited, but didn't find the thread the next iteration. This meant that we were returning null even though we had modified the suspend count. This caused the suspend count to not get decremented since the caller didn't know that the suspend count had been increased. Removing the self->thin_lock_thread_id_ = 0 in ThreadList::UnRegister fixes this race. Added a bit of additional checks and logging to prevent these issues from resurfacing, other misc cleanup. Added thread names to threads in ThreadStress. Bug: 11319866 Change-Id: I48e3a0700193b72079e450be1e924a2f88cf52e2
Diffstat (limited to 'runtime/monitor.cc')
-rw-r--r--runtime/monitor.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index af93a56264..ef9a9cee87 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -633,8 +633,7 @@ void Monitor::InflateThinLocked(Thread* self, SirtRef<mirror::Object>& obj, Lock
ScopedThreadStateChange tsc(self, kBlocked);
if (lock_word == obj->GetLockWord()) { // If lock word hasn't changed.
bool timed_out;
- Thread* owner = thread_list->SuspendThreadByThreadId(lock_word.ThinLockOwner(), false,
- &timed_out);
+ Thread* owner = thread_list->SuspendThreadByThreadId(owner_thread_id, false, &timed_out);
if (owner != nullptr) {
// We succeeded in suspending the thread, check the lock's status didn't change.
lock_word = obj->GetLockWord();