Update of /cvsroot/sbcl/sbcl
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv14154
184.108.40.206: Fix lost wakeup bug between CONDITION-WAIT and CONDITION-NOTIFY.
(Patch and write up below are actually due to Nikodemus.)
Use the waitqueue object as the data item in CONDITION-NOTIFY, and the
thread in CONDITION-WAIT.
It doesn't matter if multiple notifies use the same object -- single
thread notifying multiple times has the same meaning as multiple
threads sending one notification each, but multiple waiters must use
different objects as per following scenario:
1) Thread A calls CONDITION-WAIT on a condition variable CVAR.
Thread A sets CVAR's waitqueue-data to token A.
Thread A is preempted after the (RELEASE-MUTEX), before the
2) Thread B is run. Thread B invokes CONDITION-NOTIFY.
Thread B sets CVAR's waitqueue-data to a token B.
Thread B invokes FUTEX-WAKE which is NO-OP because no thread is
yet waiting on the futex.
3) Thread C is run. Thread C invokes CONDITION-WAIT.
Thread C sets CVAR's waitqueue-data to token C.
4) Thread A is finally run again. The call to FUTEX-WAIT compares
CVAR's waitqueue-data with token A. If token A == token C, the
wakeup is lost.
Similarly, if step 3 does not happen, and token A == token B, the
wakeup is lost.
Furthermore, consider if thread A == thread B, and step 3 does not
happen. (This can occur due to an interrupt.) Hence CONDITION-NOTIFY
cannot use the thread object as the token.
RCS file: /cvsroot/sbcl/sbcl/NEWS,v
retrieving revision 1.1729
retrieving revision 1.1730
diff -u -d -r1.1729 -r1.1730
--- NEWS 3 Apr 2010 16:46:04 -0000 1.1729
+++ NEWS 3 Apr 2010 18:06:37 -0000 1.1730
@@ -42,6 +42,10 @@
* bug fix: misoptimization of multiplication by one in
(SB-C::FLOAT-ACCURACY 0) policies.
* bug fix: miscounts in SB-PROFILE.
+ * bug fix: Fix lost wakeup bug between SB-THREAD:CONDITION-WAIT and
+ CONDITION-NOTIFY on Linux. See threads "lost wakeup in condition-wait /
+ condition-notify" (Feb 2010) and "Condition-Wait, Deadline handler, waking
+ up itself" (March 2010) for further details.
changes in sbcl-1.0.37 relative to sbcl-1.0.36:
* enhancement: Backtrace from THROW to uncaught tag on x86oids now shows
RCS file: /cvsroot/sbcl/sbcl/version.lisp-expr,v
retrieving revision 1.4826
retrieving revision 1.4827
diff -u -d -r1.4826 -r1.4827
--- version.lisp-expr 3 Apr 2010 16:46:06 -0000 1.4826
+++ version.lisp-expr 3 Apr 2010 18:06:37 -0000 1.4827
@@ -17,4 +17,4 @@
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)