]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Take cancel_lock in critical section
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 4 Mar 2026 01:12:48 +0000 (02:12 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 4 Mar 2026 01:14:43 +0000 (02:14 +0100)
read/write etc. shall be signal-safe, and take cancel_lock, so we have to
defer signal delivery while holding cancel_lock.

Reported-by: Brent Baccala <cosine@freesoft.org> 's Claude assistant
sysdeps/htl/pt-cond-timedwait.c

index d350868c2b58189cc4601bcaaba8df213ad49e78..7a5287ca9fc161f656fbee6e743256a4765d4153 100644 (file)
@@ -205,6 +205,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
 
   /* We're almost done.  Remove the unblock hook, restore the previous
      cancellation type, and check for a pending cancellation request.  */
+  HURD_CRITICAL_BEGIN;
   __pthread_mutex_lock (&self->cancel_lock);
   self->cancel_hook = NULL;
   self->cancel_hook_arg = NULL;
@@ -212,6 +213,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
   cancelled = (self->cancel_state == PTHREAD_CANCEL_ENABLE)
       && self->cancel_pending;
   __pthread_mutex_unlock (&self->cancel_lock);
+  HURD_CRITICAL_END;
 
   /* Reacquire MUTEX before returning/cancelling.  */
   __pthread_mutex_lock (mutex);