]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Semaphore and barrier reinitialization are now reported.
authorBart Van Assche <bvanassche@acm.org>
Sat, 28 Jun 2008 15:03:26 +0000 (15:03 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 28 Jun 2008 15:03:26 +0000 (15:03 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8297

exp-drd/drd_barrier.c
exp-drd/drd_semaphore.c
exp-drd/tests/Makefile.am
exp-drd/tests/pth_barrier_reinit.c [new file with mode: 0644]
exp-drd/tests/tc18_semabuse.stderr.exp
exp-drd/tests/tc20_verifywrap.stderr.exp
exp-drd/tests/tc20_verifywrap2.stderr.exp

index a7cd281dcc87e1e9319fc9cac29cf6be357aeb0c..d9c3ebbf9c195cb58d49e9720aa71fec18cbb8d7 100644 (file)
@@ -184,6 +184,19 @@ void barrier_init(const Addr barrier,
 
   tl_assert(barrier_type == pthread_barrier || barrier_type == gomp_barrier);
 
+  if (! reinitialization && barrier_type == pthread_barrier)
+  {
+    p = barrier_get(barrier);
+    if (p)
+    {
+      BarrierErrInfo bei = { barrier };
+      VG_(maybe_record_error)(VG_(get_running_tid)(),
+                              BarrierErr,
+                              VG_(get_IP)(VG_(get_running_tid)()),
+                              "Barrier reinitializatoin",
+                              &bei);
+    }
+  }
   p = barrier_get_or_allocate(barrier, barrier_type, count);
 
   if (s_trace_barrier)
index 0e97ea06ad4cfe58e5a843cbf9bced83e63070de..4bedf8f0c8bd4f1693c4a87d73d7db026044f2b0 100644 (file)
@@ -123,11 +123,22 @@ struct semaphore_info* semaphore_init(const Addr semaphore,
                  thread_get_running_tid(),
                  semaphore);
   }
-  if (semaphore_get(semaphore))
+  p = semaphore_get(semaphore);
+  if (p)
   {
-    // To do: print an error message that a semaphore is being reinitialized.
+    const ThreadId vg_tid = VG_(get_running_tid)();
+    SemaphoreErrInfo SEI = { semaphore };
+    VG_(maybe_record_error)(vg_tid,
+                            SemaphoreErr,
+                            VG_(get_IP)(vg_tid),
+                            "Semaphore reinitialization",
+                            &SEI);
   }
-  p = semaphore_get_or_allocate(semaphore);
+  else
+  {
+    p = semaphore_get_or_allocate(semaphore);
+  }
+  tl_assert(p);
   p->value = value;
   return p;
 }
index 2b78cbab8c992cf24add09fe19280038994c9040..5c7af6df927594d996e00545bcfb0b4715824ac6 100644 (file)
@@ -63,6 +63,8 @@ EXTRA_DIST =                                        \
        pth_barrier2.vgtest                         \
        pth_barrier3.stderr.exp                     \
        pth_barrier3.vgtest                         \
+       pth_barrier_reinit.stderr.exp               \
+       pth_barrier_reinit.vgtest                   \
        pth_broadcast.stderr.exp                    \
        pth_broadcast.vgtest                        \
        pth_cond_race.stderr.exp                    \
@@ -176,6 +178,7 @@ check_PROGRAMS_COMMON = \
   memory_allocation   \
   new_delete          \
   pth_barrier         \
+  pth_barrier_reinit  \
   pth_broadcast       \
   pth_cond_race       \
   pth_create_chain    \
@@ -264,6 +267,9 @@ new_delete_SOURCES          = new_delete.cpp
 pth_barrier_SOURCES         = pth_barrier.c
 pth_barrier_LDADD           = -lpthread
 
+pth_barrier_reinit_SOURCES  = pth_barrier_reinit.c
+pth_barrier_reinit_LDADD    = -lpthread
+
 pth_broadcast_SOURCES       = pth_broadcast.c
 pth_broadcast_LDADD         = -lpthread
 
diff --git a/exp-drd/tests/pth_barrier_reinit.c b/exp-drd/tests/pth_barrier_reinit.c
new file mode 100644 (file)
index 0000000..4162332
--- /dev/null
@@ -0,0 +1,9 @@
+#include <pthread.h>
+
+int main(int argc, char** argv)
+{
+  pthread_barrier_t b;
+  pthread_barrier_init(&b, 0, 1);
+  pthread_barrier_init(&b, 0, 1);
+  return 0;
+}
index 7b21919cab44424498ee57f2bf2f02be36405173..17d11f1418d025a215649c1799c4a8af59c1b91f 100644 (file)
@@ -1,6 +1,10 @@
 
+Semaphore reinitialization: semaphore 0x........
+   at 0x........: sem_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc18_semabuse.c:26)
+
 Invalid semaphore: semaphore 0x........
    at 0x........: sem_wait* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc18_semabuse.c:34)
 
-ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
index 7228c4110371cb4de23af5bfe7e308c4a43f9fce..57532209a8e87354b279d4f294aca4438d62e376 100644 (file)
@@ -84,6 +84,10 @@ Reader-writer lock not locked by calling thread: rwlock 0x.........
 ---------------- sem_* ----------------
 
 
+Semaphore reinitialization: semaphore 0x........
+   at 0x........: sem_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:231)
+
 FIXME: can't figure out how to verify wrap of sem_destroy
 
 
@@ -103,4 +107,4 @@ Destroying locked rwlock: rwlock 0x.........
 Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
    at 0x........: main (tc20_verifywrap.c:262)
 
-ERROR SUMMARY: 15 errors from 15 contexts (suppressed: 0 from 0)
+ERROR SUMMARY: 16 errors from 16 contexts (suppressed: 0 from 0)
index a43c281f7ef00b079df55d62a272cdb764770916..1c8e90985287547d109d1d3fbf3e7e17370ee8f3 100644 (file)
@@ -110,6 +110,10 @@ Reader-writer lock not locked by calling thread: rwlock 0x.........
 [1/1] semaphore_init      0x........
 [1/1] semaphore_init      0x........
 
+Semaphore reinitialization: semaphore 0x........
+   at 0x........: sem_init* (drd_pthread_intercepts.c:?)
+   by 0x........: main (tc20_verifywrap.c:231)
+
 FIXME: can't figure out how to verify wrap of sem_destroy
 
 [1/1] semaphore_pre_wait  0x........
@@ -183,4 +187,4 @@ Destroying locked mutex: mutex 0x........, recursion count 1, owner 1.
 [1/1] post_mutex_lock recursive mutex 0x........ rc 0 owner 1
 [1/1] mutex_unlock    recursive mutex 0x........ rc 1
 
-ERROR SUMMARY: 15 errors from 15 contexts (suppressed: 0 from 0)
+ERROR SUMMARY: 16 errors from 16 contexts (suppressed: 0 from 0)