]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Helgrind lock related error msg improvements.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 29 Jul 2014 20:08:15 +0000 (20:08 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 29 Jul 2014 20:08:15 +0000 (20:08 +0000)
* Add lock announcements in various helgrind errors that were not
  announcing the locks
* ensure locks are also announced in xml (note that this is compatible
  with xml protocol version 4, so no impact on GUI which properly
  implement the protocol)

Changes done:
* Like other HG record_error functions, HG_(record_error_LockOrder) is
  now passing Lock* rather than lock guest addresses.
* update exp files for tests that were showing locks without announcing them
* change tc14_laog_dinphils.c and tc15_laog_lockdel.c so as to
  have same sizes on 32 and 64 bits systems for allocated or symbol sizes.
* factorise all code that was announcing first lock observation
* enable xml lock announcement

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

18 files changed:
helgrind/hg_errors.c
helgrind/hg_errors.h
helgrind/hg_main.c
helgrind/tests/annotate_rwlock.stderr.exp
helgrind/tests/hg02_deadlock.stderr.exp
helgrind/tests/locked_vs_unlocked1_fwd.stderr.exp
helgrind/tests/locked_vs_unlocked1_rev.stderr.exp
helgrind/tests/locked_vs_unlocked2.stderr.exp
helgrind/tests/locked_vs_unlocked3.stderr.exp
helgrind/tests/tc09_bad_unlock.stderr.exp
helgrind/tests/tc10_rec_lock.stderr.exp
helgrind/tests/tc12_rwl_trivial.stderr.exp
helgrind/tests/tc13_laog1.stderr.exp
helgrind/tests/tc14_laog_dinphils.c
helgrind/tests/tc14_laog_dinphils.stderr.exp
helgrind/tests/tc15_laog_lockdel.c
helgrind/tests/tc15_laog_lockdel.stderr.exp
helgrind/tests/tc20_verifywrap.stderr.exp

index 537d98bd730c85e34b9e2dce94aeaecd0f1e52f6..321b2b7f37832ac2901594b28643956b493eb903 100644 (file)
@@ -331,8 +331,8 @@ typedef
             Thread*     thr;
             /* The first 4 fields describe the previously observed
                (should-be) ordering. */
-            Addr        shouldbe_earlier_ga;
-            Addr        shouldbe_later_ga;
+            Lock*       shouldbe_earlier_lk;
+            Lock*       shouldbe_later_lk;
             ExeContext* shouldbe_earlier_ec;
             ExeContext* shouldbe_later_ec;
             /* In principle we need to record two more stacks, from
@@ -566,8 +566,8 @@ void HG_(record_error_UnlockBogus) ( Thread* thr, Addr lock_ga )
 
 void HG_(record_error_LockOrder)(
         Thread*     thr, 
-        Addr        shouldbe_earlier_ga,
-        Addr        shouldbe_later_ga,
+        Lock*       shouldbe_earlier_lk,
+        Lock*       shouldbe_later_lk,
         ExeContext* shouldbe_earlier_ec,
         ExeContext* shouldbe_later_ec,
         ExeContext* actual_earlier_ec
@@ -579,9 +579,13 @@ void HG_(record_error_LockOrder)(
    init_XError(&xe);
    xe.tag = XE_LockOrder;
    xe.XE.LockOrder.thr       = thr;
-   xe.XE.LockOrder.shouldbe_earlier_ga = shouldbe_earlier_ga;
+   xe.XE.LockOrder.shouldbe_earlier_lk 
+      = mk_LockP_from_LockN(shouldbe_earlier_lk, 
+                            False/*!allowed_to_be_invalid*/);
    xe.XE.LockOrder.shouldbe_earlier_ec = shouldbe_earlier_ec;
-   xe.XE.LockOrder.shouldbe_later_ga   = shouldbe_later_ga;
+   xe.XE.LockOrder.shouldbe_later_lk   
+      = mk_LockP_from_LockN(shouldbe_later_lk, 
+                            False/*!allowed_to_be_invalid*/);
    xe.XE.LockOrder.shouldbe_later_ec   = shouldbe_later_ec;
    xe.XE.LockOrder.actual_earlier_ec   = actual_earlier_ec;
    // FIXME: tid vs thr
@@ -766,14 +770,19 @@ static void announce_LockP ( Lock* lk )
    tl_assert(lk->magic == LockP_MAGIC);
 
    if (VG_(clo_xml)) {
-      /* fixme: add announcement */
+      if (lk->appeared_at) {
+         emit( "  <auxwhat>Lock at %p was first observed</auxwhat>\n",
+               (void*)lk );
+         VG_(pp_ExeContext)( lk->appeared_at );
+      }
+
    } else {
       if (lk->appeared_at) {
-         VG_(umsg)( "Lock at %p was first observed\n",
+         VG_(umsg)( " Lock at %p was first observed\n",
                     (void*)lk->guestaddr );
          VG_(pp_ExeContext)( lk->appeared_at );
       } else {
-         VG_(umsg)( "Lock at %p : no stacktrace for first observation\n",
+         VG_(umsg)( " Lock at %p : no stacktrace for first observation\n",
                     (void*)lk->guestaddr );
       }
       HG_(get_and_pp_addrdescr) (lk->guestaddr);
@@ -948,8 +957,8 @@ void HG_(pp_Error) ( Error* err )
          emit( "    <text>Thread #%d: lock order \"%p before %p\" "
                     "violated</text>\n",
                (Int)xe->XE.LockOrder.thr->errmsg_index,
-               (void*)xe->XE.LockOrder.shouldbe_earlier_ga,
-               (void*)xe->XE.LockOrder.shouldbe_later_ga );
+               (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr,
+               (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
          emit( "    <hthreadid>%d</hthreadid>\n",
                (Int)xe->XE.LockOrder.thr->errmsg_index );
          emit( "  </xwhat>\n" );
@@ -958,24 +967,26 @@ void HG_(pp_Error) ( Error* err )
              && xe->XE.LockOrder.shouldbe_later_ec) {
             emit( "  <auxwhat>Required order was established by "
                   "acquisition of lock at %p</auxwhat>\n",
-                  (void*)xe->XE.LockOrder.shouldbe_earlier_ga );
+                  (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr );
             VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_earlier_ec );
             emit( "  <auxwhat>followed by a later acquisition "
                   "of lock at %p</auxwhat>\n",
-                  (void*)xe->XE.LockOrder.shouldbe_later_ga );
+                  (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
             VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_later_ec );
          }
+         announce_LockP ( xe->XE.LockOrder.shouldbe_earlier_lk );
+         announce_LockP ( xe->XE.LockOrder.shouldbe_later_lk );
 
       } else {
 
          emit( "Thread #%d: lock order \"%p before %p\" violated\n",
                (Int)xe->XE.LockOrder.thr->errmsg_index,
-               (void*)xe->XE.LockOrder.shouldbe_earlier_ga,
-               (void*)xe->XE.LockOrder.shouldbe_later_ga );
+               (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr,
+               (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
          emit( "\n" );
          emit( "Observed (incorrect) order is: "
                "acquisition of lock at %p\n",
-               (void*)xe->XE.LockOrder.shouldbe_later_ga);
+               (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr);
          if (xe->XE.LockOrder.actual_earlier_ec) {
              VG_(pp_ExeContext)(xe->XE.LockOrder.actual_earlier_ec);
          } else {
@@ -983,20 +994,23 @@ void HG_(pp_Error) ( Error* err )
          }
          emit( "\n" );
          emit(" followed by a later acquisition of lock at %p\n",
-              (void*)xe->XE.LockOrder.shouldbe_earlier_ga);
+              (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr);
          VG_(pp_ExeContext)( VG_(get_error_where)(err) );
          if (xe->XE.LockOrder.shouldbe_earlier_ec
              && xe->XE.LockOrder.shouldbe_later_ec) {
             emit("\n");
             emit( "Required order was established by "
                   "acquisition of lock at %p\n",
-                  (void*)xe->XE.LockOrder.shouldbe_earlier_ga );
+                  (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr );
             VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_earlier_ec );
             emit( "\n" );
             emit( " followed by a later acquisition of lock at %p\n",
-                  (void*)xe->XE.LockOrder.shouldbe_later_ga );
+                  (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
             VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_later_ec );
          }
+         emit("\n");
+         announce_LockP ( xe->XE.LockOrder.shouldbe_earlier_lk );
+         announce_LockP ( xe->XE.LockOrder.shouldbe_later_lk );
 
       }
 
@@ -1080,12 +1094,7 @@ void HG_(pp_Error) ( Error* err )
                (Int)xe->XE.UnlockForeign.owner->errmsg_index );
          emit( "  </xwhat>\n" );
          VG_(pp_ExeContext)( VG_(get_error_where)(err) );
-
-         if (xe->XE.UnlockForeign.lock->appeared_at) {
-            emit( "  <auxwhat>Lock at %p was first observed</auxwhat>\n",
-                  (void*)xe->XE.UnlockForeign.lock->guestaddr );
-            VG_(pp_ExeContext)( xe->XE.UnlockForeign.lock->appeared_at );
-         }
+         announce_LockP ( xe->XE.UnlockForeign.lock );
 
       } else {
 
@@ -1095,11 +1104,7 @@ void HG_(pp_Error) ( Error* err )
                (void*)xe->XE.UnlockForeign.lock->guestaddr,
                (Int)xe->XE.UnlockForeign.owner->errmsg_index );
          VG_(pp_ExeContext)( VG_(get_error_where)(err) );
-         if (xe->XE.UnlockForeign.lock->appeared_at) {
-            emit( "  Lock at %p was first observed\n",
-                  (void*)xe->XE.UnlockForeign.lock->guestaddr );
-            VG_(pp_ExeContext)( xe->XE.UnlockForeign.lock->appeared_at );
-         }
+         announce_LockP ( xe->XE.UnlockForeign.lock );
 
       }
 
@@ -1121,11 +1126,7 @@ void HG_(pp_Error) ( Error* err )
                (Int)xe->XE.UnlockUnlocked.thr->errmsg_index );
          emit( "  </xwhat>\n" );
          VG_(pp_ExeContext)( VG_(get_error_where)(err) );
-         if (xe->XE.UnlockUnlocked.lock->appeared_at) {
-            emit( "  <auxwhat>Lock at %p was first observed</auxwhat>\n",
-                  (void*)xe->XE.UnlockUnlocked.lock->guestaddr );
-            VG_(pp_ExeContext)( xe->XE.UnlockUnlocked.lock->appeared_at );
-         }
+         announce_LockP ( xe->XE.UnlockUnlocked.lock);
 
       } else {
 
@@ -1133,11 +1134,7 @@ void HG_(pp_Error) ( Error* err )
                (Int)xe->XE.UnlockUnlocked.thr->errmsg_index,
                (void*)xe->XE.UnlockUnlocked.lock->guestaddr );
          VG_(pp_ExeContext)( VG_(get_error_where)(err) );
-         if (xe->XE.UnlockUnlocked.lock->appeared_at) {
-            emit( "  Lock at %p was first observed\n",
-                  (void*)xe->XE.UnlockUnlocked.lock->guestaddr );
-            VG_(pp_ExeContext)( xe->XE.UnlockUnlocked.lock->appeared_at );
-         }
+         announce_LockP ( xe->XE.UnlockUnlocked.lock);
 
       }
 
index 02c8f50e7792d658e1e796b1364783790a474af6..03a6086bd9d828d140c37e2ab945b25a6993e924 100644 (file)
@@ -63,7 +63,7 @@ void HG_(record_error_PthAPIerror)    ( Thread*, const HChar*, Word,
                                         const HChar* );
 
 /* see the implementation for meaning of these params */
-void HG_(record_error_LockOrder)      ( Thread*, Addr, Addr,
+void HG_(record_error_LockOrder)      ( Thread*, Lock*, Lock*,
                                         ExeContext*, ExeContext*,
                                         ExeContext* );
 
index 65b045b41fda8a840251b2f11efa2b21d0a50a35..4a3005f7a8b7a3f61dbc96d920ea897935c86e1e 100644 (file)
@@ -3802,7 +3802,7 @@ static void laog__pre_thread_acquires_lock (
          tl_assert(found->src_ec);
          tl_assert(found->dst_ec);
          HG_(record_error_LockOrder)( 
-            thr, lk->guestaddr, other->guestaddr,
+            thr, lk, other,
                  found->src_ec, found->dst_ec, other->acquired_at );
       } else {
          /* Hmm.  This can't happen (can it?) */
@@ -3852,7 +3852,7 @@ static void laog__pre_thread_acquires_lock (
             held by this thread, with its 'acquired_at'. */
                     
          HG_(record_error_LockOrder)(
-            thr, lk->guestaddr, other->guestaddr,
+            thr, lk, other,
                  NULL, NULL, other->acquired_at );
       }
    }
index 9392d3939704f86a4e26feb7f0469265ca1635f7..1eefc2dcad1008dc8fdd5b38e113011e168c094b 100644 (file)
@@ -99,7 +99,7 @@ Locks held: none
 
 ----------------------------------------------------------------
 
-Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: rwlock_init (annotate_rwlock.c:54)
    by 0x........: main (annotate_rwlock.c:161)
  Address 0x........ is 0 bytes inside data symbol "s_rwlock"
index 1c33b31a63935f7cf949cff1598fa4dba4c643ce..9ec5a8b51f97adbe4a03e4c1a4785ff96c2899ee 100644 (file)
@@ -34,5 +34,18 @@ Required order was established by acquisition of lock at 0x........
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
    ...
 
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
+   by 0x........: main (hg02_deadlock.c:32)
+ Address 0x........ is 0 bytes inside data symbol "m1"
+
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
+   by 0x........: t1 (hg02_deadlock.c:10)
+   by 0x........: mythread_wrapper (hg_intercepts.c:...)
+   ...
+ Address 0x........ is 0 bytes inside data symbol "m2"
+
+
 
 ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
index 43193988ea2e20653786a678d3ba839c0b90f5c0..42ff5aa888ed954f06b7c4785211ee6b1706b0d1 100644 (file)
@@ -14,7 +14,7 @@ Thread #x was created
 
 ----------------------------------------------------------------
 
-Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
    by 0x........: child_fn (locked_vs_unlocked1.c:18)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
index bcf728cfaa5cd5b8735942084fe10f32cf5d75f4..4eec5624b891739b5540f9d18ded50b6fbfe9868 100644 (file)
@@ -14,7 +14,7 @@ Thread #x was created
 
 ----------------------------------------------------------------
 
-Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
    by 0x........: child_fn (locked_vs_unlocked1.c:18)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
index b4051fd93f41a1c80dd135c316017b3fa839423a..3463b54177cbc6696e56ab740d677c5ad22bf7b5 100644 (file)
@@ -14,17 +14,17 @@ Thread #x was created
 
 ----------------------------------------------------------------
 
-Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: main (locked_vs_unlocked2.c:58)
  Address 0x........ is 0 bytes inside data symbol "mx2a"
 
-Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: main (locked_vs_unlocked2.c:59)
  Address 0x........ is 0 bytes inside data symbol "mx2b"
 
-Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: main (locked_vs_unlocked2.c:57)
  Address 0x........ is 0 bytes inside data symbol "mx1b"
index 6e62ca73d175d36a8f56055a17f61cd9ac9bc88d..75c06e637d0ce87b92ffccb13f93aac6789ee40a 100644 (file)
@@ -14,7 +14,7 @@ Thread #x was created
 
 ----------------------------------------------------------------
 
-Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: main (locked_vs_unlocked3.c:51)
  Address 0x........ is 0 bytes inside data symbol "mx"
index 0da7639bd8b48627a3aa1218e7f8ba1cc1b2351d..bb4932489b2570d64146a7f918b2f3c919b1b4a6 100644 (file)
@@ -9,10 +9,13 @@ Thread #x unlocked a not-locked lock at 0x........
    at 0x........: pthread_mutex_unlock (hg_intercepts.c:...)
    by 0x........: nearly_main (tc09_bad_unlock.c:27)
    by 0x........: main (tc09_bad_unlock.c:49)
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: nearly_main (tc09_bad_unlock.c:23)
    by 0x........: main (tc09_bad_unlock.c:49)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by nearly_main (tc09_bad_unlock.c:16)
+
 
 ---Thread-Announcement------------------------------------------
 
@@ -29,10 +32,13 @@ Thread #x unlocked lock at 0x........ currently held by thread #x
    by 0x........: child_fn (tc09_bad_unlock.c:11)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
    ...
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: nearly_main (tc09_bad_unlock.c:31)
    by 0x........: main (tc09_bad_unlock.c:49)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by nearly_main (tc09_bad_unlock.c:16)
+
 
 ----------------------------------------------------------------
 
@@ -56,10 +62,13 @@ Thread #x unlocked a not-locked lock at 0x........
    at 0x........: pthread_mutex_unlock (hg_intercepts.c:...)
    by 0x........: nearly_main (tc09_bad_unlock.c:27)
    by 0x........: main (tc09_bad_unlock.c:50)
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: nearly_main (tc09_bad_unlock.c:23)
    by 0x........: main (tc09_bad_unlock.c:49)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by nearly_main (tc09_bad_unlock.c:16)
+
 
 ----------------------------------------------------------------
 
@@ -94,10 +103,13 @@ Thread #x unlocked lock at 0x........ currently held by thread #x
    by 0x........: child_fn (tc09_bad_unlock.c:11)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
    ...
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: nearly_main (tc09_bad_unlock.c:31)
    by 0x........: main (tc09_bad_unlock.c:49)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by nearly_main (tc09_bad_unlock.c:16)
+
 
 ----------------------------------------------------------------
 
index 93eeee3f80d3daeb8fb57496e04e91faa932df88..0f52b3f09f56876e6927c1a49dc3129499b84b58 100644 (file)
@@ -16,10 +16,13 @@ Thread #x unlocked a not-locked lock at 0x........
    at 0x........: pthread_mutex_unlock (hg_intercepts.c:...)
    by 0x........: nearly_main (tc10_rec_lock.c:42)
    by 0x........: main (tc10_rec_lock.c:47)
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_mutex_init (hg_intercepts.c:...)
    by 0x........: nearly_main (tc10_rec_lock.c:24)
    by 0x........: main (tc10_rec_lock.c:47)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by nearly_main (tc10_rec_lock.c:15)
+
 
 ----------------------------------------------------------------
 
index ff8cd7cc8febe468fbc0b54dcbbbd205bdc09d47..361a4d6777380f33ac7f68721fa71c2000c3135f 100644 (file)
@@ -9,10 +9,13 @@ Thread #x unlocked a not-locked lock at 0x........
    at 0x........: pthread_rwlock_unlock_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_unlock (hg_intercepts.c:...)
    by 0x........: main (tc12_rwl_trivial.c:35)
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_rwlock_init_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_init (hg_intercepts.c:...)
    by 0x........: main (tc12_rwl_trivial.c:24)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by main (tc12_rwl_trivial.c:20)
+
 
 
 ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
index 756300f2821bd3e6206937ff35a715c167b6f15e..3e56f251c065cd01507b1d3b5b366f3e9cdd5afc 100644 (file)
@@ -23,5 +23,18 @@ Required order was established by acquisition of lock at 0x........
    at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
    by 0x........: main (tc13_laog1.c:18)
 
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_init (hg_intercepts.c:...)
+   by 0x........: main (tc13_laog1.c:14)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by main (tc13_laog1.c:11)
+
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_init (hg_intercepts.c:...)
+   by 0x........: main (tc13_laog1.c:15)
+ Address 0x........ is on thread #x's stack
+ in frame #x, created by main (tc13_laog1.c:11)
+
+
 
 ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
index c5af8c1078a90f968b77cf42f5a0c5401a2ffe8f..ad45f693e82bfa692f1882250f577b0c6c8c20f5 100644 (file)
@@ -2,12 +2,15 @@
 #include <pthread.h>
 #include <stdlib.h>
 #include <unistd.h>
-
+#include <assert.h>
 /* Naive dining philosophers with inconsistent lock acquisition
    ordering. */
 
 static pthread_t phil[5];
-static pthread_mutex_t chop[5];
+static struct {
+   pthread_mutex_t m;
+   char pad[120 - sizeof(pthread_mutex_t)];
+} chop[5];
 
 void* dine ( void* arg )
 {
@@ -15,11 +18,11 @@ void* dine ( void* arg )
    long left = (long)arg;
    long right = (left + 1) % 5;
    for (i = 0; i < 1000/*arbitrary*/; i++) {
-      pthread_mutex_lock(&chop[left]);
-      pthread_mutex_lock(&chop[right]);
+      pthread_mutex_lock(&chop[left].m);
+      pthread_mutex_lock(&chop[right].m);
       /* eating */
-      pthread_mutex_unlock(&chop[left]);
-      pthread_mutex_unlock(&chop[right]);
+      pthread_mutex_unlock(&chop[left].m);
+      pthread_mutex_unlock(&chop[right].m);
    }
    return NULL;
 }
@@ -27,8 +30,10 @@ void* dine ( void* arg )
 int main ( void )
 {
    long i;
+   assert(sizeof(pthread_mutex_t) <= 120);
+
    for (i = 0; i < 5; i++)
-      pthread_mutex_init( &chop[i], NULL);
+      pthread_mutex_init( &chop[i].m, NULL);
 
    for (i = 0; i < 5; i++)
       pthread_create(&phil[i], NULL, dine, (void*)i );
index bcc5c745da23d0eecde864b1e17be7814cff3a7b..3bf02bf6280984bca9927a6d00e6c1fa5ba6d837 100644 (file)
@@ -4,7 +4,7 @@
 Thread #x was created
    ...
    by 0x........: pthread_create@* (hg_intercepts.c:...)
-   by 0x........: main (tc14_laog_dinphils.c:34)
+   by 0x........: main (tc14_laog_dinphils.c:39)
 
 ----------------------------------------------------------------
 
@@ -12,15 +12,26 @@ Thread #x: lock order "0x........ before 0x........" violated
 
 Observed (incorrect) order is: acquisition of lock at 0x........
    at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
-   by 0x........: dine (tc14_laog_dinphils.c:18)
+   by 0x........: dine (tc14_laog_dinphils.c:21)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
    ...
 
  followed by a later acquisition of lock at 0x........
    at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
-   by 0x........: dine (tc14_laog_dinphils.c:19)
+   by 0x........: dine (tc14_laog_dinphils.c:22)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
    ...
 
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_init (hg_intercepts.c:...)
+   by 0x........: main (tc14_laog_dinphils.c:36)
+ Address 0x........ is 0 bytes inside data symbol "chop"
+
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_init (hg_intercepts.c:...)
+   by 0x........: main (tc14_laog_dinphils.c:36)
+ Address 0x........ is 480 bytes inside data symbol "chop"
+
+
 
 ERROR SUMMARY: 1000 errors from 1 contexts (suppressed: 0 from 0)
index 68668b188adaa3be635d0254e1b612fd98181331..5b2607d39b617566f212501caed551e18d12a637 100644 (file)
@@ -12,9 +12,9 @@ int main ( void )
 {
    int r;
    pthread_mutex_t *mx1, *mx2;
-
-   mx1 = malloc(sizeof(pthread_mutex_t));
-   mx2 = malloc(sizeof(pthread_mutex_t));
+   assert (sizeof(pthread_mutex_t) <= 120);
+   mx1 = malloc(120 + sizeof(pthread_mutex_t) - sizeof(pthread_mutex_t));
+   mx2 = malloc(120 + sizeof(pthread_mutex_t) - sizeof(pthread_mutex_t));
 
    assert(mx1);
    assert(mx2);
index 675b95b35bd158f2fd66a8f3cee9782248a921c2..945010e13209343c8fdab460a05be8d36a199e59 100644 (file)
@@ -25,6 +25,23 @@ Required order was established by acquisition of lock at 0x........
    at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
    by 0x........: main (tc15_laog_lockdel.c:28)
 
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_init (hg_intercepts.c:...)
+   by 0x........: main (tc15_laog_lockdel.c:22)
+ Address 0x........ is 0 bytes inside a block of size 120 alloc'd
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (tc15_laog_lockdel.c:16)
+ Block was alloc'd by thread #x
+
+ Lock at 0x........ was first observed
+   at 0x........: pthread_mutex_init (hg_intercepts.c:...)
+   by 0x........: main (tc15_laog_lockdel.c:23)
+ Address 0x........ is 0 bytes inside a block of size 120 alloc'd
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (tc15_laog_lockdel.c:17)
+ Block was alloc'd by thread #x
+
+
 Free 2 and re-allocate it.  This gives it a new identity,
 so a second locking sequence 2 -> 1 should now be OK.
 done
index aaab563bd09f13b8b5d9d8fc15098131914abca7..4d9f4c4db99f134d142b891427818dabf4e9f0a1 100644 (file)
@@ -157,10 +157,13 @@ Thread #x unlocked a not-locked lock at 0x........
    at 0x........: pthread_rwlock_unlock_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_unlock (hg_intercepts.c:...)
    by 0x........: main (tc20_verifywrap.c:179)
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_rwlock_init_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_init (hg_intercepts.c:...)
    by 0x........: main (tc20_verifywrap.c:178)
+ Location 0x........ is 0 bytes inside local var "rwl"
+ declared at tc20_verifywrap.c:47, in frame #x of thread x
+
 
 (1) no error on next line
 (2) no error on next line
@@ -171,10 +174,13 @@ Thread #x unlocked a not-locked lock at 0x........
    at 0x........: pthread_rwlock_unlock_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_unlock (hg_intercepts.c:...)
    by 0x........: main (tc20_verifywrap.c:196)
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_rwlock_init_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_init (hg_intercepts.c:...)
    by 0x........: main (tc20_verifywrap.c:186)
+ Location 0x........ is 0 bytes inside local var "rwl2"
+ declared at tc20_verifywrap.c:48, in frame #x of thread x
+
 
 (4) no error on next line
 (5) no error on next line
@@ -187,10 +193,13 @@ Thread #x unlocked a not-locked lock at 0x........
    at 0x........: pthread_rwlock_unlock_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_unlock (hg_intercepts.c:...)
    by 0x........: main (tc20_verifywrap.c:212)
 Lock at 0x........ was first observed
+ Lock at 0x........ was first observed
    at 0x........: pthread_rwlock_init_WRK (hg_intercepts.c:...)
    by 0x........: pthread_rwlock_init (hg_intercepts.c:...)
    by 0x........: main (tc20_verifywrap.c:186)
+ Location 0x........ is 0 bytes inside local var "rwl2"
+ declared at tc20_verifywrap.c:48, in frame #x of thread x
+
 
 
 ---------------- sem_* ----------------