]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When the "not a mutex" error message is printed, the offending address is now printed...
authorBart Van Assche <bvanassche@acm.org>
Mon, 24 Mar 2008 09:29:38 +0000 (09:29 +0000)
committerBart Van Assche <bvanassche@acm.org>
Mon, 24 Mar 2008 09:29:38 +0000 (09:29 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7773

exp-drd/drd_error.c
exp-drd/drd_mutex.c
exp-drd/tests/tc09_bad_unlock.stderr.exp
exp-drd/tests/tc20_verifywrap.stderr.exp
exp-drd/tests/tc20_verifywrap2.stderr.exp
exp-drd/tests/tc23_bogus_condwait.stderr.exp

index 4389e7bf238d77c910966677b4c545ba93bbbab0..86c40a2dcd44f36e6e33f6d275916de94bea02a1 100644 (file)
@@ -133,12 +133,22 @@ static void drd_tool_error_pp(Error* const e)
   case MutexErr: {
     MutexErrInfo* p = (MutexErrInfo*)(VG_(get_error_extra)(e));
     tl_assert(p);
-    VG_(message)(Vg_UserMsg,
-                 "%s: mutex 0x%lx, recursion count %d, owner %d.",
-                 VG_(get_error_string)(e),
-                 p->mutex,
-                 p->recursion_count,
-                 p->owner);
+    if (p->recursion_count >= 0)
+    {
+      VG_(message)(Vg_UserMsg,
+                   "%s: mutex 0x%lx, recursion count %d, owner %d.",
+                   VG_(get_error_string)(e),
+                   p->mutex,
+                   p->recursion_count,
+                   p->owner);
+    }
+    else
+    {
+      VG_(message)(Vg_UserMsg,
+                   "%s: mutex 0x%lx.",
+                   VG_(get_error_string)(e),
+                   p->mutex);
+    }
     VG_(pp_ExeContext)(VG_(get_error_where)(e));
     break;
   }
index e72286ac1572f7ca86c0fbfd58a7af84ea6cc2a4..2cb36bedaf16f805370c4ac2d42ab3ede207f3a2 100644 (file)
@@ -72,6 +72,8 @@ void mutex_initialize(struct mutex_info* const p,
 /** Deallocate the memory that was allocated by mutex_initialize(). */
 static void mutex_cleanup(struct mutex_info* p)
 {
+  tl_assert(p);
+
   if (s_trace_mutex)
   {
     VG_(message)(Vg_UserMsg,
@@ -96,6 +98,16 @@ static void mutex_cleanup(struct mutex_info* p)
   p->last_locked_segment = 0;
 }
 
+static void not_a_mutex(const Addr mutex)
+{
+  MutexErrInfo MEI = { mutex, -1, DRD_INVALID_THREADID };
+  VG_(maybe_record_error)(VG_(get_running_tid)(),
+                          MutexErr,
+                          VG_(get_IP)(VG_(get_running_tid)()),
+                          "Not a mutex",
+                          &MEI);
+}
+
 static
 struct mutex_info*
 mutex_get_or_allocate(const Addr mutex, const MutexT mutex_type)
@@ -111,12 +123,7 @@ mutex_get_or_allocate(const Addr mutex, const MutexT mutex_type)
 
   if (clientobj_present(mutex, mutex + 1))
   {
-    GenericErrInfo GEI;
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            GenericErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "Not a mutex",
-                            &GEI);
+    not_a_mutex(mutex);
     return 0;
   }
 
@@ -149,12 +156,7 @@ mutex_init(const Addr mutex, const MutexT mutex_type)
 
   if (mutex_type == mutex_type_invalid_mutex)
   {
-    GenericErrInfo GEI;
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            GenericErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "Not a mutex",
-                            &GEI);
+    not_a_mutex(mutex);
     return 0;
   }
 
@@ -184,12 +186,7 @@ void mutex_post_destroy(const Addr mutex)
   p = mutex_get(mutex);
   if (p == 0)
   {
-    GenericErrInfo GEI;
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            GenericErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "Not a mutex",
-                            &GEI);
+    not_a_mutex(mutex);
     return;
   }
 
@@ -213,7 +210,7 @@ void mutex_pre_lock(const Addr mutex, const MutexT mutex_type,
                  "[%d/%d] pre_mutex_lock  %s 0x%lx rc %d owner %d",
                  VG_(get_running_tid)(),
                  thread_get_running_tid(),
-                 mutex_get_typename(p),
+                 p ? mutex_get_typename(p) : "(?)",
                  mutex,
                  p ? p->recursion_count : -1,
                  p ? p->owner : DRD_INVALID_THREADID);
@@ -221,12 +218,7 @@ void mutex_pre_lock(const Addr mutex, const MutexT mutex_type,
 
   if (p == 0)
   {
-    GenericErrInfo GEI;
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            GenericErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "Not a mutex",
-                            &GEI);
+    not_a_mutex(mutex);
     return;
   }
 
@@ -234,12 +226,7 @@ void mutex_pre_lock(const Addr mutex, const MutexT mutex_type,
 
   if (mutex_type == mutex_type_invalid_mutex)
   {
-    GenericErrInfo GEI;
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            GenericErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "Not a mutex",
-                            &GEI);
+    not_a_mutex(mutex);
     return;
   }
 
@@ -331,19 +318,14 @@ void mutex_unlock(const Addr mutex, const MutexT mutex_type)
                  "[%d/%d] mutex_unlock    %s 0x%lx rc %d",
                  vg_tid,
                  drd_tid,
-                 p ? mutex_get_typename(p) : "?",
+                 p ? mutex_get_typename(p) : "(?)",
                  mutex,
                  p ? p->recursion_count : 0);
   }
 
   if (p == 0 || mutex_type == mutex_type_invalid_mutex)
   {
-    GenericErrInfo GEI;
-    VG_(maybe_record_error)(vg_tid,
-                            GenericErr,
-                            VG_(get_IP)(vg_tid),
-                            "Not a mutex",
-                            &GEI);
+    not_a_mutex(mutex);
     return;
   }
 
index e90f3cd8daa7210084c66b947b57a64610da0b20..a7e55444aa1f2f80a7c401989c79e20ae8f8e9c5 100644 (file)
@@ -13,7 +13,7 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1
    by 0x........: clone (in /...libc...)
 
 Thread 1:
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
    by 0x........: nearly_main (tc09_bad_unlock.c:41)
    by 0x........: main (tc09_bad_unlock.c:49)
@@ -36,7 +36,7 @@ Mutex not locked by calling thread: mutex 0x........, recursion count 1, owner 1
    by 0x........: clone (in /...libc...)
 
 Thread 1:
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
    by 0x........: nearly_main (tc09_bad_unlock.c:41)
    by 0x........: main (tc09_bad_unlock.c:50)
index 6a60bc01d8d79527f86d31cf574e982cdcebba8b..64508f1b89b1885729c6777c80d138b1a0fdf5e4 100644 (file)
@@ -17,7 +17,7 @@ Other segment end (thread 0/2)
 ---------------- pthread_mutex_lock et al ----------------
 
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:92)
 
@@ -25,19 +25,19 @@ Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: pthread_mutex_destroy (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:102)
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:108)
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_trylock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:116)
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_timedlock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:121)
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:125)
 
index 7345f23b78da9b1d0b1474804f403ca3ad33b4c5..14ef8d137148c37cd675b5cfc8a8a1b8b96d12c5 100644 (file)
@@ -18,7 +18,7 @@ Other segment end (thread 0/2)
 
 [1/1] mutex_init      invalid mutex 0x........
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:92)
 [1/1] mutex_init      mutex 0x........
@@ -31,25 +31,25 @@ Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    by 0x........: main (tc20_verifywrap.c:102)
 [1/1] pre_mutex_lock  invalid mutex 0x........ rc 0 owner 0
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:108)
 [1/1] post_mutex_lock invalid mutex 0x........ rc 0 owner 0
 [1/1] pre_mutex_lock  invalid mutex 0x........ rc 0 owner 0
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_trylock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:116)
 [1/1] post_mutex_lock invalid mutex 0x........ rc 0 owner 0
 [1/1] pre_mutex_lock  invalid mutex 0x........ rc 0 owner 0
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_timedlock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:121)
 [1/1] post_mutex_lock invalid mutex 0x........ rc 0 owner 0
 [1/1] mutex_unlock    invalid mutex 0x........ rc 0
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:125)
 
index e0caaa71098393d94d0f2473d6fed7791646df13..afbf17b7bacee7a90bb78e23e5252fcdc27a076a 100644 (file)
@@ -1,5 +1,5 @@
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc23_bogus_condwait.c:69)
 
@@ -7,7 +7,7 @@ Mutex not locked: mutex 0x........, recursion count 0, owner 0.
    at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc23_bogus_condwait.c:72)
 
-Not a mutex
+Not a mutex: mutex 0x.........
    at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc23_bogus_condwait.c:75)