An error message is now printed before attempting to lock a non-recursive mutex recursively.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7490 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/exp-drd/tests/recursive_mutex.c b/exp-drd/tests/recursive_mutex.c
index 62d90e3..069c862 100644
--- a/exp-drd/tests/recursive_mutex.c
+++ b/exp-drd/tests/recursive_mutex.c
@@ -1,5 +1,5 @@
-/** Initialize a recursive mutex and lock it twice.
- * No error messages may be printed.
+/** Initialize several kinds of mutexes and lock each mutex twice.
+ * Note: locking a regular mutex twice causes a deadlock.
*/
#define _GNU_SOURCE
@@ -17,6 +17,9 @@
int main(int argc, char** argv)
{
+ /* Let the program abort after 3 seconds instead of leaving it deadlocked. */
+ alarm(3);
+
{
pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
@@ -51,7 +54,9 @@
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
printf("Non-recursive mutex.\n");
+ fflush(stdout);
lock_twice(&m);
}
+ printf("Done.\n");
return 0;
}