This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[COMMITTED] Make error checking effective in nptl/tst-cond25.c.
- From: Torvald Riegel <triegel at redhat dot com>
- To: GLIBC Devel <libc-alpha at sourceware dot org>
- Date: Mon, 16 Feb 2015 18:15:51 +0100
- Subject: [COMMITTED] Make error checking effective in nptl/tst-cond25.c.
- Authentication-results: sourceware.org; auth=none
pthread_mutex_unlock currently does not check for errors in case of the
default mutex types (which is okay). When testing the new condvar
implementation, this lead to nptl/tst-cond25.c not aborting when
pthread_cond_wait returned after cancellation without actually having
acquired the mutex. This patch fixes that. Tested on x86_64-linux.
2015-02-16 Torvald Riegel <triegel@redhat.com>
* nptl/tst-cond25.c (cleanup): Explicitly check that the mutex is
acquired.
commit 35264d14426e1e3ca7b595db1de76208374b56e3
Author: Torvald Riegel <triegel@redhat.com>
Date: Sun Feb 15 17:33:31 2015 +0100
Make error checking effective in nptl/tst-cond25.c.
diff --git a/nptl/tst-cond25.c b/nptl/tst-cond25.c
index d80d8f7..be0bec4 100644
--- a/nptl/tst-cond25.c
+++ b/nptl/tst-cond25.c
@@ -40,7 +40,15 @@ pthread_cond_t cond;
void cleanup (void *u)
{
- /* pthread_cond_wait should always return with the mutex locked. */
+ /* pthread_cond_wait should always return with the mutex locked. The
+ pthread_mutex_unlock implementation does not actually check whether we
+ own the mutex for several mutex kinds, so check this explicitly. */
+ int ret = pthread_mutex_trylock (&mutex);
+ if (ret != EDEADLK && ret != EBUSY)
+ {
+ printf ("mutex not locked in cleanup %d\n", ret);
+ abort ();
+ }
if (pthread_mutex_unlock (&mutex))
abort ();
}