This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ 19944] nptl/pthread_mutex*lock: don't ignore unknown error codes


pthread_mutex_lock(), pthread_mutex_trylock() and pthread_mutex_unlock()
ignore the return code from the futex syscall unless it is something
the function expects.
This patch forwards the error code to the user instead of simply
ignoring it.

2016-04-13  Sebastian Andrzej Siewior  <bigeasy@linutronix.de>
	[BZ #19944]
	* nptl/pthread_mutex_lock.c: return unhandled sys_futex error.
	* nptl/pthread_mutex_trylock.c: return unhandled sys_futex
	error.
	* nptl/pthread_mutex_unlock.c: return unhandled sys_futex error.
---
 nptl/pthread_mutex_lock.c    | 3 ++-
 nptl/pthread_mutex_trylock.c | 2 ++
 nptl/pthread_mutex_unlock.c  | 5 ++++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index bdfa529f639b..f1b9aa1b9f84 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -354,7 +354,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
 		/* Delay the thread indefinitely.  */
 		while (1)
 		  pause_not_cancel ();
-	      }
+	      } else if (INTERNAL_SYSCALL_ERROR_P (e, __err))
+		      return INTERNAL_SYSCALL_ERRNO (e, __err);
 
 	    oldval = mutex->__data.__lock;
 
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 48c7865702ba..45c416b75cf2 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -265,6 +265,8 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 		THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
 
 		return EBUSY;
+	      } else if (INTERNAL_SYSCALL_ERROR_P (e, __err)) {
+		      return INTERNAL_SYSCALL_ERRNO (e, __err);
 	      }
 
 	    oldval = mutex->__data.__lock;
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index 334ce383420e..787fb3017c44 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -243,8 +243,11 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
 								  tid)))
 	{
 	  INTERNAL_SYSCALL_DECL (__err);
-	  INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock,
+	  int e = INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock,
 			    __lll_private_flag (FUTEX_UNLOCK_PI, private));
+
+	  if (INTERNAL_SYSCALL_ERROR_P (e, __err))
+		  return INTERNAL_SYSCALL_ERRNO (e, __err);
 	}
 
       THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
-- 
2.8.0.rc3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]