From aa69f19a937b679816ef10e8620ea1141bb1734b Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Thu, 26 Nov 2020 10:54:04 -0300 Subject: nptl: Add EOVERFLOW checks for futex calls Some futex-internal calls require additional check for EOVERFLOW (as indicated by [1] [2] [3]). For both mutex and rwlock code, EOVERFLOW is handle as ETIMEDOUT; since it indicate to the caller that the blocking operation could not be issued. For mutex it avoids a possible issue where PTHREAD_MUTEX_ROBUST_* might assume EOVERFLOW indicate futex has succeed, and for PTHREAD_MUTEX_PP_* it avoid a potential busy infinite loop. For rwlock and semaphores, it also avoids potential busy infinite loops. Checked on x86_64-linux-gnu and i686-linux-gnu, although EOVERFLOW won't be possible with current usage (since all timeouts on 32-bit architectures with 32-bit time_t support will be in the range of 32-bit time_t). [1] https://sourceware.org/pipermail/libc-alpha/2020-November/120079.html [2] https://sourceware.org/pipermail/libc-alpha/2020-November/120080.html [3] https://sourceware.org/pipermail/libc-alpha/2020-November/120127.html --- nptl/pthread_cond_wait.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nptl/pthread_cond_wait.c') diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c index 685dbca32f..02d11c61db 100644 --- a/nptl/pthread_cond_wait.c +++ b/nptl/pthread_cond_wait.c @@ -506,7 +506,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, __pthread_cleanup_pop (&buffer, 0); - if (__glibc_unlikely (err == ETIMEDOUT)) + if (__glibc_unlikely (err == ETIMEDOUT || err == EOVERFLOW)) { __condvar_dec_grefs (cond, g, private); /* If we timed out, we effectively cancel waiting. Note that @@ -515,7 +515,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, __condvar_quiesce_and_switch_g1 and us trying to acquire the lock during cancellation is not possible. */ __condvar_cancel_waiting (cond, seq, g, private); - result = ETIMEDOUT; + result = err; goto done; } else -- cgit 1.4.1