|
From: <sv...@va...> - 2008-06-28 15:03:22
|
Author: bart
Date: 2008-06-28 16:03:26 +0100 (Sat, 28 Jun 2008)
New Revision: 8297
Log:
Semaphore and barrier reinitialization are now reported.
Added:
trunk/exp-drd/tests/pth_barrier_reinit.c
Modified:
trunk/exp-drd/drd_barrier.c
trunk/exp-drd/drd_semaphore.c
trunk/exp-drd/tests/Makefile.am
trunk/exp-drd/tests/tc18_semabuse.stderr.exp
trunk/exp-drd/tests/tc20_verifywrap.stderr.exp
trunk/exp-drd/tests/tc20_verifywrap2.stderr.exp
Modified: trunk/exp-drd/drd_barrier.c
===================================================================
--- trunk/exp-drd/drd_barrier.c 2008-06-28 13:40:41 UTC (rev 8296)
+++ trunk/exp-drd/drd_barrier.c 2008-06-28 15:03:26 UTC (rev 8297)
@@ -184,6 +184,19 @@
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)
Modified: trunk/exp-drd/drd_semaphore.c
===================================================================
--- trunk/exp-drd/drd_semaphore.c 2008-06-28 13:40:41 UTC (rev 8296)
+++ trunk/exp-drd/drd_semaphore.c 2008-06-28 15:03:26 UTC (rev 8297)
@@ -123,11 +123,22 @@
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;
}
Modified: trunk/exp-drd/tests/Makefile.am
===================================================================
--- trunk/exp-drd/tests/Makefile.am 2008-06-28 13:40:41 UTC (rev 8296)
+++ trunk/exp-drd/tests/Makefile.am 2008-06-28 15:03:26 UTC (rev 8297)
@@ -63,6 +63,8 @@
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 @@
memory_allocation \
new_delete \
pth_barrier \
+ pth_barrier_reinit \
pth_broadcast \
pth_cond_race \
pth_create_chain \
@@ -264,6 +267,9 @@
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
Added: trunk/exp-drd/tests/pth_barrier_reinit.c
===================================================================
--- trunk/exp-drd/tests/pth_barrier_reinit.c (rev 0)
+++ trunk/exp-drd/tests/pth_barrier_reinit.c 2008-06-28 15:03:26 UTC (rev 8297)
@@ -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;
+}
Modified: trunk/exp-drd/tests/tc18_semabuse.stderr.exp
===================================================================
--- trunk/exp-drd/tests/tc18_semabuse.stderr.exp 2008-06-28 13:40:41 UTC (rev 8296)
+++ trunk/exp-drd/tests/tc18_semabuse.stderr.exp 2008-06-28 15:03:26 UTC (rev 8297)
@@ -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)
Modified: trunk/exp-drd/tests/tc20_verifywrap.stderr.exp
===================================================================
--- trunk/exp-drd/tests/tc20_verifywrap.stderr.exp 2008-06-28 13:40:41 UTC (rev 8296)
+++ trunk/exp-drd/tests/tc20_verifywrap.stderr.exp 2008-06-28 15:03:26 UTC (rev 8297)
@@ -84,6 +84,10 @@
---------------- 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 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)
Modified: trunk/exp-drd/tests/tc20_verifywrap2.stderr.exp
===================================================================
--- trunk/exp-drd/tests/tc20_verifywrap2.stderr.exp 2008-06-28 13:40:41 UTC (rev 8296)
+++ trunk/exp-drd/tests/tc20_verifywrap2.stderr.exp 2008-06-28 15:03:26 UTC (rev 8297)
@@ -110,6 +110,10 @@
[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 @@
[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)
|