From: Bart Van Assche Date: Sat, 28 Jun 2008 11:53:01 +0000 (+0000) Subject: Delayed thread termination such that the "other segment" information is included... X-Git-Tag: svn/VALGRIND_3_4_0~420 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58985b01c327083e6870898ef07f018615d84ddc;p=thirdparty%2Fvalgrind.git Delayed thread termination such that the "other segment" information is included in the data race reports. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8294 --- diff --git a/exp-drd/tests/rwlock_race.c b/exp-drd/tests/rwlock_race.c index d7c6af233d..d3d29efa10 100644 --- a/exp-drd/tests/rwlock_race.c +++ b/exp-drd/tests/rwlock_race.c @@ -8,19 +8,27 @@ #define _GNU_SOURCE 1 -#include #include +#include +#include #include "../drd_clientreq.h" static pthread_rwlock_t s_rwlock; static int s_racy; -static void* thread(void* arg) +static void sleep_ms(const int ms) +{ + struct timespec delay = { ms / 1000, (ms % 1000) * 1000 * 1000 }; + nanosleep(&delay, 0); +} + +static void* thread_func(void* arg) { pthread_rwlock_rdlock(&s_rwlock); s_racy++; pthread_rwlock_unlock(&s_rwlock); + sleep_ms(100); return 0; } @@ -36,8 +44,8 @@ int main(int argc, char** argv) #endif pthread_rwlock_init(&s_rwlock, 0); - pthread_create(&thread1, 0, thread, 0); - pthread_create(&thread2, 0, thread, 0); + pthread_create(&thread1, 0, thread_func, 0); + pthread_create(&thread2, 0, thread_func, 0); pthread_join(thread1, 0); pthread_join(thread2, 0); pthread_rwlock_destroy(&s_rwlock); diff --git a/exp-drd/tests/rwlock_race.stderr.exp b/exp-drd/tests/rwlock_race.stderr.exp index 560d313b71..ec4d8b9dbe 100644 --- a/exp-drd/tests/rwlock_race.stderr.exp +++ b/exp-drd/tests/rwlock_race.stderr.exp @@ -1,28 +1,44 @@ -Thread 2: -Conflicting load by thread 2/3 at 0x........ size 4 - at 0x........: thread (rwlock_race.c:?) +Thread 3: +Conflicting load by thread 3/3 at 0x........ size 4 + at 0x........: thread_func (rwlock_race.c:?) by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?) by 0x........: (within libpthread-?.?.so) by 0x........: clone (in /...libc...) Location 0x........ is 0 bytes inside local var "s_racy" -declared at rwlock_race.c:17, in frame #? of thread 2 -Other segment start (thread 0/2) - (thread finished, call stack no longer available) -Other segment end (thread 0/2) - (thread finished, call stack no longer available) +declared at rwlock_race.c:18, in frame #? of thread 3 +Other segment start (thread 2/2) + at 0x........: pthread_rwlock_rdlock* (drd_pthread_intercepts.c:?) + by 0x........: thread_func (rwlock_race.c:?) + by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?) + by 0x........: (within libpthread-?.?.so) + by 0x........: clone (in /...libc...) +Other segment end (thread 2/2) + at 0x........: pthread_rwlock_unlock* (drd_pthread_intercepts.c:?) + by 0x........: thread_func (rwlock_race.c:?) + by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?) + by 0x........: (within libpthread-?.?.so) + by 0x........: clone (in /...libc...) -Conflicting store by thread 2/3 at 0x........ size 4 - at 0x........: thread (rwlock_race.c:?) +Conflicting store by thread 3/3 at 0x........ size 4 + at 0x........: thread_func (rwlock_race.c:?) by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?) by 0x........: (within libpthread-?.?.so) by 0x........: clone (in /...libc...) Location 0x........ is 0 bytes inside local var "s_racy" -declared at rwlock_race.c:17, in frame #? of thread 2 -Other segment start (thread 0/2) - (thread finished, call stack no longer available) -Other segment end (thread 0/2) - (thread finished, call stack no longer available) +declared at rwlock_race.c:18, in frame #? of thread 3 +Other segment start (thread 2/2) + at 0x........: pthread_rwlock_rdlock* (drd_pthread_intercepts.c:?) + by 0x........: thread_func (rwlock_race.c:?) + by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?) + by 0x........: (within libpthread-?.?.so) + by 0x........: clone (in /...libc...) +Other segment end (thread 2/2) + at 0x........: pthread_rwlock_unlock* (drd_pthread_intercepts.c:?) + by 0x........: thread_func (rwlock_race.c:?) + by 0x........: vg_thread_wrapper (drd_pthread_intercepts.c:?) + by 0x........: (within libpthread-?.?.so) + by 0x........: clone (in /...libc...) Result: 2 ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)