1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Fix possible deadlock in 'scm_sigaction_for_thread'.

Fixes <https://bugs.gnu.org/64666>.

* libguile/scmsigs.c (scm_sigaction_for_thread): Swap the
'scm_dynwind_block_asyncs' and 'scm_i_dynwind_pthread_mutex_lock'
calls.
* NEWS: Update.
This commit is contained in:
Ludovic Courtès 2023-07-16 18:31:57 +02:00
parent 896960dade
commit 85520354a8
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 8 additions and 2 deletions

2
NEWS
View file

@ -31,6 +31,8 @@ the compiler reports it as "possibly unused".
(<https://bugs.gnu.org/62501>)
** Fix 'system*' with non-file input/output/error port
(<https://bugs.gnu.org/63024>)
** Fix possible deadlock in 'sigaction' (aka. 'scm_sigaction_for_thread')
(<https://bugs.gnu.org/64666>)
** Hashing of UTF-8 symbols with non-ASCII characters avoids corruption
(<https://bugs.gnu.org/56413>)

View file

@ -1,4 +1,4 @@
/* Copyright 1995-2002,2004,2006-2009,2011,2013-2014,2017-2018
/* Copyright 1995-2002,2004,2006-2009,2011,2013-2014,2017-2018,2023
Free Software Foundation, Inc.
This file is part of Guile.
@ -336,8 +336,12 @@ SCM_DEFINE (scm_sigaction_for_thread, "sigaction", 1, 3, 0,
scm_i_ensure_signal_delivery_thread ();
scm_dynwind_begin (0);
scm_i_dynwind_pthread_mutex_lock (&signal_handler_lock);
/* Among the pending asyncs, there might be signal handlers that will
call this very function. Thus, to avoid deadlocks, block asyncs
before grabbing SIGNAL_HANDLER_LOCK. */
scm_dynwind_block_asyncs ();
scm_i_dynwind_pthread_mutex_lock (&signal_handler_lock);
old_handler = SCM_SIMPLE_VECTOR_REF (*signal_handlers, csig);
if (SCM_UNBNDP (handler))