[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 03/06: Avoid module resolution in 'call-with-new-thread'
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] 03/06: Avoid module resolution in 'call-with-new-thread'. |
Date: |
Sun, 16 Jul 2023 16:39:41 -0400 (EDT) |
civodul pushed a commit to branch main
in repository guile.
commit dcccaddf7bceb3eef00d036b666b9510682009d4
Author: Timothy Sample <samplet@ngyro.com>
AuthorDate: Tue Apr 11 10:22:46 2023 -0600
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>
---
NEWS | 2 ++
module/ice-9/threads.scm | 10 +++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
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".
(<https://bugs.gnu.org/63024>)
** Fix possible deadlock in 'sigaction' (aka. 'scm_sigaction_for_thread')
(<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
(<https://bugs.gnu.org/56413>)
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 <https://bugs.gnu.org/62691>.
+ ((setter thread-join-data) thread (cons cv mutex))
(signal-condition-variable cv)
(unlock-mutex mutex)
(call-with-unblocked-asyncs
- [Guile-commits] branch main updated (99e727add -> a0805cc27), Ludovic Courtès, 2023/07/16
- [Guile-commits] 02/06: Fix dangling pointers in `environ'., Ludovic Courtès, 2023/07/16
- [Guile-commits] 06/06: Revert "Mention package GNU Autopoint in README.", Ludovic Courtès, 2023/07/16
- [Guile-commits] 01/06: Fix typos throughout codebase., Ludovic Courtès, 2023/07/16
- [Guile-commits] 03/06: Avoid module resolution in 'call-with-new-thread'.,
Ludovic Courtès <=
- [Guile-commits] 04/06: r7rs: 'read-u8' now defaults to 'current-input-port'., Ludovic Courtès, 2023/07/16
- [Guile-commits] 05/06: doc: Use archived URL from Internet Archive for syntax-rules primer., Ludovic Courtès, 2023/07/16