]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
- Bug fix: swapped order of VG_(OSetGen_Remove)() and
authorBart Van Assche <bvanassche@acm.org>
Sat, 21 Feb 2009 16:17:50 +0000 (16:17 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 21 Feb 2009 16:17:50 +0000 (16:17 +0000)
  (*p->any.cleanup)(p) such that the "first observed at" information is
  now included in error messages.
- Performance optimization: started using VG_(OSetGen_ResetIterAt)().

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9214

13 files changed:
drd/drd_clientobj.c
drd/tests/bar_bad.stderr.exp
drd/tests/tc04_free_lock.stderr.exp
drd/tests/tc09_bad_unlock.stderr.exp
drd/tests/tc20_verifywrap.stderr.exp-glibc2.3
drd/tests/tc20_verifywrap.stderr.exp-glibc2.5
drd/tests/tc20_verifywrap.stderr.exp-glibc2.5-ppc
drd/tests/tc20_verifywrap.stderr.exp-glibc2.8
drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3
drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3-b
drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5
drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5-ppc
drd/tests/tc20_verifywrap2.stderr.exp-glibc2.8

index d1f5f9641c2c061de2e6cac775a5966b8e6baf34..6c7620d8a20cba7a404c494305e7e69b9641391f 100644 (file)
@@ -85,9 +85,10 @@ DrdClientobj* DRD_(clientobj_get_any)(const Addr addr)
   return VG_(OSetGen_Lookup)(s_clientobj_set, &addr);
 }
 
-/** Return the data associated with the client object at client address addr
- *  and that has object type t. Return 0 if there is no client object in the
- *  set with the specified start address.
+/**
+ * Return the data associated with the client object at client address addr
+ * and that has object type t. Return 0 if there is no client object in the
+ * set with the specified start address.
  */
 DrdClientobj* DRD_(clientobj_get)(const Addr addr, const ObjType t)
 {
@@ -144,6 +145,12 @@ DrdClientobj* DRD_(clientobj_add)(const Addr a1, const ObjType t)
   return p;
 }
 
+/**
+ * Remove the information that was stored about the client object.
+ *
+ * @param[in] addr Address of the client object in the client address space.
+ * @param[in] t    Type of the client object.
+ */
 Bool DRD_(clientobj_remove)(const Addr addr, const ObjType t)
 {
   DrdClientobj* p;
@@ -154,27 +161,28 @@ Bool DRD_(clientobj_remove)(const Addr addr, const ObjType t)
   return clientobj_remove_obj(p);
 }
 
+/**
+ * Remove the information that was stored about the client object p.
+ *
+ * @note The order of operations below is important. The client object is
+ *   removed from the client object set after the cleanup function has been
+ *   called such that if the cleanup function can still use the function
+ *   DRD_(clientobj_get_any)(). This happens e.g. in the function
+ *   first_observed() in drd_error.c.
+ */
 static Bool clientobj_remove_obj(DrdClientobj* const p)
 {
-  DrdClientobj* q;
+  tl_assert(p);
 
   if (s_trace_clientobj)
   {
     VG_(message)(Vg_UserMsg, "Removing client object 0x%lx of type %d",
                  p->any.a1, p->any.type);
-#if 0
-    VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(),
-                               VG_(clo_backtrace_size));
-#endif
   }
 
-  tl_assert(p);
-  q = VG_(OSetGen_Remove)(s_clientobj_set, &p->any.a1);
-  tl_assert(p == q);
-
-  tl_assert(VG_(OSetGen_Lookup)(s_clientobj_set, &p->any.a1) == 0);
   tl_assert(p->any.cleanup);
   (*p->any.cleanup)(p);
+  VG_(OSetGen_Remove)(s_clientobj_set, &p->any.a1);
   VG_(OSetGen_FreeNode)(s_clientobj_set, p);
   return True;
 }
@@ -196,13 +204,10 @@ void DRD_(clientobj_stop_using_mem)(const Addr a1, const Addr a2)
     if (a1 <= p->any.a1 && p->any.a1 < a2)
     {
       removed_at = p->any.a1;
-      DRD_(clientobj_remove)(p->any.a1, p->any.type);
+      clientobj_remove_obj(p);
       /* The above call removes an element from the oset and hence */
       /* invalidates the iterator. Set the iterator back.          */
-      VG_(OSetGen_ResetIter)(s_clientobj_set);
-      while ((p = VG_(OSetGen_Next)(s_clientobj_set)) != 0
-             && p->any.a1 <= removed_at)
-      { }
+      VG_(OSetGen_ResetIterAt)(s_clientobj_set, &removed_at);
     }
     else
     {
index a159938542be658d922be4a8e56316703a073eb0..6b50433a512bf156c6f8eaf34856c32514ed450b 100644 (file)
@@ -34,6 +34,9 @@ barrier 0x........ was first observed at:
 Destruction of barrier that is being waited upon: barrier 0x........
    at 0x........: pthread_barrier_destroy (drd_pthread_intercepts.c:?)
    by 0x........: main (bar_bad.c:?)
+barrier 0x........ was first observed at:
+   at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (bar_bad.c:?)
 
 destroy a barrier that was never initialised
 
@@ -44,3 +47,6 @@ Not a barrier
 Destruction of barrier that is being waited upon: barrier 0x........
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (bar_bad.c:?)
+barrier 0x........ was first observed at:
+   at 0x........: pthread_barrier_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (bar_bad.c:?)
index fbb85cd91fad9f43fea67ba4b866484d5c59d5b8..76657545dbc91390f564543b03e13cc94a575830 100644 (file)
@@ -2,17 +2,32 @@
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (tc04_free_lock.c:24)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc04_free_lock.c:20)
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: bar (tc04_free_lock.c:40)
    by 0x........: main (tc04_free_lock.c:26)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
+   by 0x........: bar (tc04_free_lock.c:38)
+   by 0x........: main (tc04_free_lock.c:26)
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: foo (tc04_free_lock.c:49)
    by 0x........: main (tc04_free_lock.c:27)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: foo (tc04_free_lock.c:46)
+   by 0x........: main (tc04_free_lock.c:27)
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: bar (tc04_free_lock.c:40)
    by 0x........: main (tc04_free_lock.c:28)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
+   by 0x........: bar (tc04_free_lock.c:38)
+   by 0x........: main (tc04_free_lock.c:28)
 
 ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
index b8bf909daec64f051935dbd93d99825e21230417..f78b25f56d5f2265d4347ee210c4ae7d7c000239 100644 (file)
@@ -29,6 +29,10 @@ The object at address 0x........ is not a mutex.
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: nearly_main (tc09_bad_unlock.c:45)
    by 0x........: main (tc09_bad_unlock.c:49)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: nearly_main (tc09_bad_unlock.c:31)
+   by 0x........: main (tc09_bad_unlock.c:49)
 ---------------------
 
 Mutex not locked by calling thread: mutex 0x........, recursion count 0, owner 1.
@@ -61,5 +65,9 @@ The object at address 0x........ is not a mutex.
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: nearly_main (tc09_bad_unlock.c:45)
    by 0x........: main (tc09_bad_unlock.c:50)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: nearly_main (tc09_bad_unlock.c:31)
+   by 0x........: main (tc09_bad_unlock.c:50)
 
 ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)
index a715c838a17acfcdbff0eedc6b0fd0ae7c43c911..e8bae84d66a0b5f4c61d1c442b794ea8ad0c8140 100644 (file)
@@ -24,6 +24,9 @@ The object at address 0x........ is not a mutex.
 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)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:100)
 
 make pthread_mutex_lock fail: skipped on glibc < 2.4
 
@@ -132,8 +135,14 @@ FIXME: can't figure out how to verify wrap of sem_post
 
 Destroying locked rwlock: rwlock 0x.........
    at 0x........: main (tc20_verifywrap.c:262)
+rwlock 0x........ was first observed at:
+   at 0x........: pthread_rwlock_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:216)
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: main (tc20_verifywrap.c:262)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:145)
 
 ERROR SUMMARY: 15 errors from 15 contexts (suppressed: 0 from 0)
index 1e531a84c859a8820be522d11bf9e4034cdd4203..62a85db61114690cdc603d7104fd9fcd346f4845 100644 (file)
@@ -24,6 +24,9 @@ The object at address 0x........ is not a mutex.
 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)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:100)
 
 The object at address 0x........ is not a mutex.
    at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
@@ -136,8 +139,14 @@ FIXME: can't figure out how to verify wrap of sem_post
 
 Destroying locked rwlock: rwlock 0x.........
    at 0x........: main (tc20_verifywrap.c:262)
+rwlock 0x........ was first observed at:
+   at 0x........: pthread_rwlock_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:216)
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: main (tc20_verifywrap.c:262)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:145)
 
 ERROR SUMMARY: 16 errors from 16 contexts (suppressed: 0 from 0)
index 93e3d8a55ce3c99f370dac7a67b8ee8279d28bd4..802e53c4cbeae2ae8a44d270bf6721ab9dbb9802 100644 (file)
@@ -24,6 +24,9 @@ The object at address 0x........ is not a mutex.
 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)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:100)
 
 The object at address 0x........ is not a mutex.
    at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
index f4290f4910f5676a776a05c3157bc42fc79380bc..6e9c12c0f90f38c640a59f4ad260904b4e37a3d7 100644 (file)
@@ -24,6 +24,9 @@ The object at address 0x........ is not a mutex.
 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)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:100)
 
 The object at address 0x........ is not a mutex.
    at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
index 9e29a244e5e72dbf24ef9e6fb5de9ae60d80cef5..5e0a3d0c33ce16b6dafa318ee3e42adc5c4ffd0f 100644 (file)
@@ -159,10 +159,16 @@ FIXME: can't figure out how to verify wrap of sem_post
 
 Destroying locked rwlock: rwlock 0x.........
    at 0x........: main (tc20_verifywrap.c:262)
+rwlock 0x........ was first observed at:
+   at 0x........: pthread_rwlock_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:216)
 [1/1] mutex_destroy   error checking mutex 0x........ rc 1 owner 1
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: main (tc20_verifywrap.c:262)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:145)
 [1/1] mutex_destroy   invalid mutex 0x........ rc 0 owner 0
 [1/1] mutex_trylock   recursive mutex 0x........ rc 0 owner 0
 [1/1] post_mutex_lock recursive mutex 0x........ rc 0 owner 0
index 4be55c3794f8611ec2372ec31447780ce74210df..cc9e1e9c733aa919d1c29baff6018c6acb82b305 100644 (file)
@@ -159,10 +159,16 @@ FIXME: can't figure out how to verify wrap of sem_post
 
 Destroying locked rwlock: rwlock 0x.........
    at 0x........: main (tc20_verifywrap.c:262)
+rwlock 0x........ was first observed at:
+   at 0x........: pthread_rwlock_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:216)
 [1/1] mutex_destroy   error checking mutex 0x........ rc 1 owner 1
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: main (tc20_verifywrap.c:262)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:145)
 [1/1] mutex_destroy   invalid mutex 0x........ rc 0 owner 0
 [1/1] mutex_trylock   recursive mutex 0x........ rc 0 owner 0
 [1/1] post_mutex_lock recursive mutex 0x........ rc 0 owner 0
index 9b729075ea3c14a766ce9a55ef09c00cc0c2b6ff..5e38246cd9b03d26428722088e282dd540d35d22 100644 (file)
@@ -29,6 +29,9 @@ The object at address 0x........ is not a mutex.
 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)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:100)
 [1/1] mutex_trylock   invalid mutex 0x........ rc 0 owner 0
 
 The object at address 0x........ is not a mutex.
@@ -165,10 +168,16 @@ FIXME: can't figure out how to verify wrap of sem_post
 
 Destroying locked rwlock: rwlock 0x.........
    at 0x........: main (tc20_verifywrap.c:262)
+rwlock 0x........ was first observed at:
+   at 0x........: pthread_rwlock_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:216)
 [1/1] mutex_destroy   error checking mutex 0x........ rc 1 owner 1
 
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: main (tc20_verifywrap.c:262)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:145)
 [1/1] mutex_destroy   invalid mutex 0x........ rc 0 owner 0
 [1/1] mutex_trylock   recursive mutex 0x........ rc 0 owner 0
 [1/1] post_mutex_lock recursive mutex 0x........ rc 0 owner 0
index 0b7f0c14ae45f2ee8b0a3781bddcd1c1610f8477..1479e9b4ecf1b4479f0a285e96a797e9f1fc67c3 100644 (file)
@@ -29,6 +29,9 @@ The object at address 0x........ is not a mutex.
 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)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:100)
 [1/1] mutex_trylock   invalid mutex 0x........ rc 0 owner 0
 
 The object at address 0x........ is not a mutex.
index 50077791484319d01622fff1396d651251e8fe04..cb887e017cb4f5a636ec858eef852b110da14a2d 100644 (file)
@@ -29,6 +29,9 @@ The object at address 0x........ is not a mutex.
 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)
+mutex 0x........ was first observed at:
+   at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:100)
 [1/1] mutex_trylock   invalid mutex 0x........ rc 0 owner 0
 
 The object at address 0x........ is not a mutex.