0.9.17.2: fix two potential GC deadlocks
authorNikodemus Siivola <nikodemus@random-state.net>
Wed, 27 Sep 2006 11:03:17 +0000 (11:03 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Wed, 27 Sep 2006 11:03:17 +0000 (11:03 +0000)
commitbfb7c2d573bacfd9c5f3f243b7c1589f81f11406
tree69269b08fb1efb8ebdfa2eeac88d9cc57fc6c424
parentc3554861f21143572552a2ce8095fa9a13effa4f
0.9.17.2: fix two potential GC deadlocks
 * Dying threads used to grab session and all-threads locks
   with GC inhibited, which was bad:
    1. T1 has the lock, GC not inhibited
       T2 in HANDLE-THREAD-EXIT waiting for the lock, GC inhibited
    2. GC is triggered
    3. T1 stopped while holding the lock
       T2 deadlocks waiting for T1 to release the lock.
 * Mark threads dead while holding the *ALL-THREADS-LOCK*, so that
     (unless (thread-alive-p th)
       (assert (not (member th (list-all-threads)))))
   cannot fail.
 * Since dying threads can now trigger GCs, don't run after-gc hooks
   and finalizers if the thread has been marked as dead.
 * Move all thread cleanup logic to HANDLE-THREAD exit.
NEWS
src/code/gc.lisp
src/code/target-thread.lisp
src/runtime/interrupt.c
src/runtime/thread.c
tests/threads.impure.lisp
version.lisp-expr