1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Avoid module resolution in 'call-with-new-thread'.

Fixes <https://bugs.gnu.org/62691>.
Reported by Михаил Бахтерев <mike.bakhterev@gmail.com>.

* module/ice-9/threads.scm (call-with-new-thread): Do not use 'set!'
to set object properties while the calling thread is waiting on the
new thread to initialize.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Timothy Sample 2023-04-11 10:22:46 -06:00 committed by Ludovic Courtès
parent 84bf840322
commit dcccaddf7b
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 11 additions and 1 deletions

2
NEWS
View file

@ -33,6 +33,8 @@ the compiler reports it as "possibly unused".
(<https://bugs.gnu.org/63024>) (<https://bugs.gnu.org/63024>)
** Fix possible deadlock in 'sigaction' (aka. 'scm_sigaction_for_thread') ** Fix possible deadlock in 'sigaction' (aka. 'scm_sigaction_for_thread')
(<https://bugs.gnu.org/64666>) (<https://bugs.gnu.org/64666>)
** Avoid module resolution in 'call-with-new-thread', which could deadlock
(<https://bugs.gnu.org/62691>)
** Hashing of UTF-8 symbols with non-ASCII characters avoids corruption ** Hashing of UTF-8 symbols with non-ASCII characters avoids corruption
(<https://bugs.gnu.org/56413>) (<https://bugs.gnu.org/56413>)

View file

@ -151,7 +151,15 @@ Once @var{thunk} or @var{handler} returns, the return value is made the
(lambda () (lambda ()
(lock-mutex mutex) (lock-mutex mutex)
(set! thread (current-thread)) (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 <https://bugs.gnu.org/62691>.
((setter thread-join-data) thread (cons cv mutex))
(signal-condition-variable cv) (signal-condition-variable cv)
(unlock-mutex mutex) (unlock-mutex mutex)
(call-with-unblocked-asyncs (call-with-unblocked-asyncs