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)
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;
}
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 \
memory_allocation \
new_delete \
pth_barrier \
+ pth_barrier_reinit \
pth_broadcast \
pth_cond_race \
pth_create_chain \
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
--- /dev/null
+#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;
+}
+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)
---------------- 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
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)
[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........
[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)