From 4d8be78a84614f58e409e1078f9b0ba1212784a7 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 29 May 2019 04:24:40 +0000 Subject: [PATCH] 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) --- src/runtime/gcfinal.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) -- 2.25.1