diff --git a/NEWS b/NEWS index 81f19744a..239edca83 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,8 @@ the compiler reports it as "possibly unused". () ** Fix possible deadlock in 'sigaction' (aka. 'scm_sigaction_for_thread') () +** Avoid module resolution in 'call-with-new-thread', which could deadlock + () ** Hashing of UTF-8 symbols with non-ASCII characters avoids corruption () diff --git a/module/ice-9/threads.scm b/module/ice-9/threads.scm index 5a13cec1d..048d8b085 100644 --- a/module/ice-9/threads.scm +++ b/module/ice-9/threads.scm @@ -151,7 +151,15 @@ Once @var{thunk} or @var{handler} returns, the return value is made the (lambda () (lock-mutex mutex) (set! thread (current-thread)) - (set! (thread-join-data thread) (cons cv mutex)) + ;; Rather than use the 'set!' syntax here, we use the + ;; underlying 'setter' generic function to set the + ;; 'thread-join-data' property on 'thread'. This is + ;; because 'set!' will try to resolve 'setter' in the + ;; '(guile)' module, which means acquiring the + ;; 'autoload' mutex. If the calling thread is + ;; already holding that mutex, this will result in + ;; deadlock. See . + ((setter thread-join-data) thread (cons cv mutex)) (signal-condition-variable cv) (unlock-mutex mutex) (call-with-unblocked-asyncs