Block interrupts, _then_ lock.
authorTaylor R Campbell <campbell@mumble.net>
Wed, 29 May 2019 04:24:40 +0000 (04:24 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 29 May 2019 05:00:39 +0000 (05:00 +0000)
Otherwise an interrupt might try to acquire the lock while we already
hold it, leading to deadlock.

src/runtime/gcfinal.scm

index 8bee6bc698cfdf6510997393008e23c0f5f8aac1..34437313706c720f9e5de32e921630a38189ca76 100644 (file)
@@ -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)