From e46cd75f182a3d738c5e2ef3cc90b2f0b1de56ee Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 31 Oct 2012 16:56:18 -0700 Subject: Fix race condition in thread pool shutdown We were not holding the task queue lock when we did broadcast, causing a race where a thread waits on the CV after the broadcast. Fixes dex2oat deadlocking. Change-Id: I84f30020511c2bd43f71d9b7b392720bd8d03eab --- src/mutex.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mutex.cc') diff --git a/src/mutex.cc b/src/mutex.cc index a4347ba6d2..0e33f3cc48 100644 --- a/src/mutex.cc +++ b/src/mutex.cc @@ -749,6 +749,7 @@ void ConditionVariable::Broadcast(Thread* self) { DCHECK(self == NULL || self == Thread::Current()); // TODO: enable below, there's a race in thread creation that causes false failures currently. // guard_.AssertExclusiveHeld(self); + DCHECK_EQ(guard_.GetExclusiveOwnerTid(), SafeGetTid(self)); #if ART_USE_FUTEXES if (num_waiters_ > 0) { android_atomic_inc(&state_); // Indicate a wake has occurred to waiters coming in. -- cgit v1.2.3-59-g8ed1b