From: Taylor R Campbell Date: Wed, 29 May 2019 04:24:40 +0000 (+0000) Subject: Block interrupts, _then_ lock. X-Git-Tag: mit-scheme-pucked-10.1.11~6^2~17 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=9a3417ac7a5f294fbbda397086d890029d45343a;p=mit-scheme.git Block interrupts, _then_ lock. Otherwise an interrupt might try to acquire the lock while we already hold it, leading to deadlock. --- diff --git a/src/runtime/gcfinal.scm b/src/runtime/gcfinal.scm index 8bee6bc69..344373137 100644 --- a/src/runtime/gcfinal.scm +++ b/src/runtime/gcfinal.scm @@ -111,10 +111,10 @@ USA. (loop (cdr items) items)))))) (define (with-finalizer-lock finalizer thunk) - (with-thread-mutex-lock - (gc-finalizer-mutex finalizer) - (lambda () - (without-interruption thunk)))) + (without-interruption + (lambda () + (with-thread-mutex-lock (gc-finalizer-mutex finalizer) + thunk)))) (define (with-gc-finalizer-lock finalizer thunk) (guarantee-gc-finalizer finalizer 'with-gc-finalizer-lock)