From e92674cb7337355dc4dd6317219010e5d1ce7e1c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 2 Feb 2010 12:24:05 -0700 Subject: [PATCH] fix race condition in monitorWait We don't want to check Thread::waiting until we have re-acquired the monitor, since another thread might notify us between releasing Thread::lock and acquiring the monitor. --- src/machine.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/machine.h b/src/machine.h index 24fe9ab70b..441eecc6a0 100644 --- a/src/machine.h +++ b/src/machine.h @@ -2508,7 +2508,6 @@ monitorWait(Thread* t, object monitor, int64_t time) bool interrupted; unsigned depth; - bool stillWaiting; PROTECT(t, monitor); @@ -2524,13 +2523,11 @@ monitorWait(Thread* t, object monitor, int64_t time) ENTER(t, Thread::IdleState); interrupted = t->lock->wait(t->systemThread, time); - - stillWaiting = t->waiting; } monitorAcquire(t, monitor); - if (stillWaiting) { + if (t->waiting) { monitorRemoveWait(t, monitor); }