1.0.37.14: fix the other half of the WAIT-ON-SEMAPHORE buglet
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 29 Mar 2010 08:05:11 +0000 (08:05 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 29 Mar 2010 08:05:11 +0000 (08:05 +0000)
 * ATOMIC-DECF doesn't do any good if the other write isn't atomic as
   well: even though we are always holding the lock while incrementing
   the waitcount, the possibly unlocked but atomic decrement means the
   increment needs to be atomic too.

src/code/target-thread.lisp
version.lisp-expr

index 51e4c42..72d0af4 100644 (file)
@@ -678,7 +678,11 @@ negative. Else blocks until the semaphore can be decremented."
           (setf (semaphore-%count semaphore) (1- count))
           (unwind-protect
                (progn
-                 (incf (semaphore-waitcount semaphore))
+                 ;; Need to use ATOMIC-INCF despite the lock, because on our
+                 ;; way out from here we might not be locked anymore -- so
+                 ;; another thread might be tweaking this in parallel using
+                 ;; ATOMIC-DECF.
+                 (atomic-incf (semaphore-waitcount semaphore))
                  (loop until (plusp (setf count (semaphore-%count semaphore)))
                        do (condition-wait (semaphore-queue semaphore)
                                           (semaphore-mutex semaphore)))
index 12c3089..5093ca6 100644 (file)
@@ -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".)
-"1.0.37.13"
+"1.0.37.14"