]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merged trunk revisions 10261, 10262, 10265, 10266 and 10269.
authorBart Van Assche <bvanassche@acm.org>
Sat, 6 Jun 2009 19:22:26 +0000 (19:22 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 6 Jun 2009 19:22:26 +0000 (19:22 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_4_BRANCH@10270

12 files changed:
drd/drd_barrier.c
drd/drd_gomp_intercepts.c
drd/drd_main.c
drd/drd_mutex.c
drd/drd_rwlock.c
drd/drd_semaphore.c
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
glibc-2.X-drd.supp

index 0dd53d3418244eb6c63397283c92b63b49297e20..a8568cafc95f452566686d25a916e70d46576609 100644 (file)
@@ -388,6 +388,10 @@ void barrier_post_wait(const DrdThreadId tid, const Addr barrier,
       VG_(OSetGen_Insert)(p->oset, q);
       tl_assert(VG_(OSetGen_Lookup)(p->oset, &word_tid) == q);
     }
+
+    thread_new_segment(tid);
+    s_barrier_segment_creation_count++;
+
     VG_(OSetGen_ResetIter)(p->oset);
     for ( ; (r = VG_(OSetGen_Next)(p->oset)) != 0; )
     {
@@ -398,9 +402,6 @@ void barrier_post_wait(const DrdThreadId tid, const Addr barrier,
       }
     }
 
-    thread_new_segment(tid);
-    s_barrier_segment_creation_count++;
-
     if (--p->post_waiters_left <= 0)
     {
       p->post_iteration    = 1 - p->post_iteration;
index 4922b49c16d979bbcd6ac401a3cf5fb98c2a292e..7072325d6c02421fcfdb9bbea741589a9ce4edc8 100644 (file)
@@ -59,6 +59,8 @@ typedef void* gomp_barrier_t;
 
 // Function definitions.
 
+#if 0
+
 GOMP_FUNC(void, gompZubarrierZuinit, // gomp_barrier_init
           gomp_barrier_t* barrier, unsigned count)
 {
@@ -115,3 +117,5 @@ GOMP_FUNC(void, gompZubarrierZuwait, // gomp_barrier_wait
   VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_BARRIER_WAIT,
                              barrier, gomp_barrier, 1, 0, 0);
 }
+
+#endif
index 0dc981cc10040919fc914d96930aae6786a4ab4c..bdd6a94cea72fa18f75d4315c6342d956c82b458 100644 (file)
@@ -646,9 +646,10 @@ void drd_post_thread_join(DrdThreadId drd_joiner, DrdThreadId drd_joinee)
 {
   tl_assert(IsValidDrdThreadId(drd_joiner));
   tl_assert(IsValidDrdThreadId(drd_joinee));
-  thread_new_segment(drd_joinee);
-  thread_combine_vc(drd_joiner, drd_joinee);
+
   thread_new_segment(drd_joiner);
+  thread_combine_vc(drd_joiner, drd_joinee);
+  thread_new_segment(drd_joinee);
 
   if (s_drd_trace_fork_join)
   {
index fc3b8af14a116ef03df0642a552ee3c4ad760016..09275b8b107709c20cdf80669ced6ec85f103b6d 100644 (file)
@@ -301,13 +301,14 @@ void mutex_post_lock(const Addr mutex, const Bool took_lock,
   {
     const DrdThreadId last_owner = p->owner;
 
+    thread_new_segment(drd_tid);
+    s_mutex_segment_creation_count++;
+
     if (last_owner != drd_tid && last_owner != DRD_INVALID_THREADID)
     {
       tl_assert(p->last_locked_segment);
       thread_combine_vc2(drd_tid, &p->last_locked_segment->vc);
     }
-    thread_new_segment(drd_tid);
-    s_mutex_segment_creation_count++;
 
     p->owner           = drd_tid;
     p->acquiry_time_ms = VG_(read_millisecond_timer)();
index 20800a4466edcd03d200b0a9902504e47adf25bf..cb9200e9e949bf1a76c1593ef4dd30e3716227ab 100644 (file)
@@ -368,10 +368,10 @@ void rwlock_post_rdlock(const Addr rwlock, const Bool took_lock)
   q = lookup_or_insert_node(p->thread_info, drd_tid);
   if (++q->reader_nesting_count == 1)
   {
-    rwlock_combine_other_vc(p, drd_tid, False);
     q->last_lock_was_writer_lock = False;
     thread_new_segment(drd_tid);
     s_rwlock_segment_creation_count++;
+    rwlock_combine_other_vc(p, drd_tid, False);
 
     p->acquiry_time_ms = VG_(read_millisecond_timer)();
     p->acquired_at     = VG_(record_ExeContext)(VG_(get_running_tid)(), 0);
@@ -446,9 +446,9 @@ void rwlock_post_wrlock(const Addr rwlock, const Bool took_lock)
   q->writer_nesting_count++;
   q->last_lock_was_writer_lock = True;
   tl_assert(q->writer_nesting_count == 1);
-  rwlock_combine_other_vc(p, drd_tid, True);
   thread_new_segment(drd_tid);
   s_rwlock_segment_creation_count++;
+  rwlock_combine_other_vc(p, drd_tid, True);
   p->acquiry_time_ms = VG_(read_millisecond_timer)();
   p->acquired_at     = VG_(record_ExeContext)(VG_(get_running_tid)(), 0);
 }
index e5c867ce853c7be2c0f1baf6d1b6d88615669581..c2878ef7f7251bb567ef192a94f09f50b14b8e67 100644 (file)
@@ -227,9 +227,17 @@ void semaphore_pre_wait(const Addr semaphore)
 
   p = semaphore_get_or_allocate(semaphore);
   tl_assert(p);
-  tl_assert((int)p->waiters >= 0);
   p->waiters++;
-  tl_assert(p->waiters > 0);
+
+   if ((int)p->waiters <= 0)
+   {
+      SemaphoreErrInfo sei = { semaphore };
+      VG_(maybe_record_error)(VG_(get_running_tid)(),
+                              SemaphoreErr,
+                              VG_(get_IP)(VG_(get_running_tid)()),
+                              "Invalid semaphore",
+                              &sei);
+   }
 }
 
 /** Called after sem_wait() finished.
@@ -253,12 +261,21 @@ void semaphore_post_wait(const DrdThreadId tid, const Addr semaphore,
                  p ? p->value : 0,
                  p ? p->value - 1 : 0);
   }
-  tl_assert(p);
-  tl_assert(p->waiters > 0);
-  p->waiters--;
-  tl_assert((int)p->waiters >= 0);
-  tl_assert((int)p->value >= 0);
-  if (p->value == 0)
+
+  if (p)
+  {
+    p->waiters--;
+    p->value--;
+  }
+
+  /*
+   * Note: if another thread destroyed and reinitialized a semaphore while
+   * the current thread was waiting in sem_wait, p->waiters may have been
+   * set to zero by semaphore_initialize() after
+   * semaphore_pre_wait() has finished before
+   * semaphore_post_wait() has been called.
+   */
+  if (p == NULL || (int)p->value < 0 || (int)p->waiters < 0)
   {
     SemaphoreErrInfo sei = { semaphore };
     VG_(maybe_record_error)(VG_(get_running_tid)(),
@@ -268,8 +285,7 @@ void semaphore_post_wait(const DrdThreadId tid, const Addr semaphore,
                             &sei);
     return;
   }
-  p->value--;
-  tl_assert((int)p->value >= 0);
+
   if (p->waits_to_skip > 0)
     p->waits_to_skip--;
   else
@@ -278,14 +294,15 @@ void semaphore_post_wait(const DrdThreadId tid, const Addr semaphore,
     tl_assert(sg);
     if (sg)
     {
+      thread_new_segment(tid);
+      s_semaphore_segment_creation_count++;
+
       if (p->last_sem_post_tid != tid
           && p->last_sem_post_tid != DRD_INVALID_THREADID)
       {
         thread_combine_vc2(tid, &sg->vc);
       }
       sg_put(sg);
-      thread_new_segment(tid);
-      s_semaphore_segment_creation_count++;
     }
   }
 }
@@ -310,11 +327,11 @@ void semaphore_pre_post(const DrdThreadId tid, const Addr semaphore)
   }
 
   p->last_sem_post_tid = tid;
-  thread_new_segment(tid);
   sg = 0;
   thread_get_latest_segment(&sg, tid);
   tl_assert(sg);
   segment_push(p, sg);
+  thread_new_segment(tid);
   s_semaphore_segment_creation_count++;
 }
 
index 1c36ddf96bf366af673f8f96c7c1a42e65b9f169..c6dbd796874d86202a93efd5bd87857476680b0a 100644 (file)
@@ -134,11 +134,11 @@ Invalid semaphore: semaphore 0x........
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........ value 0 -> 1
+[1/1] semaphore_post      0x........ value 4294967295 -> 0
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........ value 1
+[1/1] semaphore_destroy   0x........ value 0
 
 ------------ dealloc of mem holding locks ------------
 
index 7fb1fe8e1d2c13e86d568ec65b78b09293de2ff3..06b5bb794bb54f135e6885316b5c0fefee85df48 100644 (file)
@@ -148,11 +148,11 @@ Invalid semaphore: semaphore 0x........
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........ value 0 -> 1
+[1/1] semaphore_post      0x........ value 4294967295 -> 0
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........ value 1
+[1/1] semaphore_destroy   0x........ value 0
 
 ------------ dealloc of mem holding locks ------------
 
index aff9624e449a21eadea23f5beacbb9ced27d1905..b94d930bc992fcd836d174ff0c21694d715bde76 100644 (file)
@@ -133,11 +133,11 @@ Invalid semaphore: semaphore 0x........
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........ value 0 -> 1
+[1/1] semaphore_post      0x........ value 4294967295 -> 0
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........ value 1
+[1/1] semaphore_destroy   0x........ value 0
 
 ------------ dealloc of mem holding locks ------------
 
index a7360fc1add51a6e263ba8bdba4a2c5618018309..69eade241840ffcf2226b245c6da51a0011e03d2 100644 (file)
@@ -133,11 +133,11 @@ Invalid semaphore: semaphore 0x........
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........ value 0 -> 1
+[1/1] semaphore_post      0x........ value 4294967295 -> 0
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........ value 1
+[1/1] semaphore_destroy   0x........ value 0
 
 ------------ dealloc of mem holding locks ------------
 
index 939ae4106f51dc97b8282b9b314daefc3bd9c0e6..c86fb1ad23e2d009c8bf9a16fa690e76d42cc764 100644 (file)
@@ -126,11 +126,11 @@ Invalid semaphore: semaphore 0x........
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........ value 0 -> 1
+[1/1] semaphore_post      0x........ value 4294967295 -> 0
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........ value 1
+[1/1] semaphore_destroy   0x........ value 0
 
 ------------ dealloc of mem holding locks ------------
 
index 30437f531ebbca4757fd8ce5b0d392706f4bf37b..7b171ace94cf80b4a69804a8a68ac19d550b1898 100644 (file)
    gomp
    drd:ConflictingAccess
    obj:/usr/lib*/libgomp.so*
-   obj:/usr/lib*/libgomp.so*
 }
 {
    libX11-XCreateFontSet