]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Delayed thread termination such that the "other segment" information is included...
authorBart Van Assche <bvanassche@acm.org>
Sat, 28 Jun 2008 11:53:01 +0000 (11:53 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 28 Jun 2008 11:53:01 +0000 (11:53 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8294

exp-drd/tests/rwlock_race.c
exp-drd/tests/rwlock_race.stderr.exp

index d7c6af233da3e5899827ae1e6490ace21d6041c8..d3d29efa107d50386008aa51e6daa1ba9af82f58 100644 (file)
@@ -8,19 +8,27 @@
 
 #define _GNU_SOURCE 1
 
-#include <stdio.h>
 #include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
 #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);
index 560d313b71c7d6c2153c1784e61d58aff6e2d9a8..ec4d8b9dbefd63beb1244602bdd56d99702e1c86 100644 (file)
@@ -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)