From: Taylor R Campbell Date: Wed, 29 May 2019 04:24:40 +0000 (+0000) Subject: Block interrupts, _then_ lock. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=4d8be78a84614f58e409e1078f9b0ba1212784a7;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. (cherry picked from commit 9a3417ac7a5f294fbbda397086d890029d45343a) --- 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)