summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-12-30 00:40:18 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-12-30 00:41:24 +0100
commit289b098c9e21e2805e3835f9b5780235ab14a290 (patch)
treede5836a64ca9067d4c6a70da94e715d27705f003 /sysdeps
parentc923cd8c496c7f253f327361a65c737233c7ebbd (diff)
downloadglibc-289b098c9e21e2805e3835f9b5780235ab14a290.tar.gz
glibc-289b098c9e21e2805e3835f9b5780235ab14a290.tar.xz
glibc-289b098c9e21e2805e3835f9b5780235ab14a290.zip
htl: Fix sem_wait race between read and gsync_wait
If the value changes between sem_wait's read and the gsync_wait call,
the kernel will return KERN_INVALID_ARGUMENT, which we have to interpret
as the value having already changed.

This fixes applications (e.g. libgo) seeing sem_wait erroneously return
KERN_INVALID_ARGUMENT.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/htl/sem-timedwait.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sysdeps/htl/sem-timedwait.c b/sysdeps/htl/sem-timedwait.c
index 1b1eec9f59..c610804b08 100644
--- a/sysdeps/htl/sem-timedwait.c
+++ b/sysdeps/htl/sem-timedwait.c
@@ -79,7 +79,7 @@ __sem_timedwait_internal (sem_t *restrict sem,
 		      ((unsigned int *) &sem->data) + SEM_VALUE_OFFSET,
 		      0, flags);
 
-	  if (err != 0)
+	  if (err != 0 && err != KERN_INVALID_ARGUMENT)
 	    {
 	      /* Error, interruption or timeout, abort.  */
 	      if (err == KERN_TIMEDOUT)
@@ -138,7 +138,7 @@ __sem_timedwait_internal (sem_t *restrict sem,
 		err = __lll_wait_intr (&isem->value,
 			  SEM_NWAITERS_MASK, flags);
 
-	      if (err != 0)
+	      if (err != 0 && err != KERN_INVALID_ARGUMENT)
 		{
 		  /* Error, interruption or timeout, abort.  */
 		  if (err == KERN_TIMEDOUT)