algorithm than in 3.3.x.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8750
#include "pub_tool_aspacemgr.h"
#include "pub_tool_execontext.h"
#include "pub_tool_errormgr.h"
-
+#include "pub_tool_options.h" // VG_(clo_verbosity)
#include "hg_basics.h"
#include "hg_wordset.h"
#include "hg_lock_n_thread.h"
VG_(printf)("<<GC ends, next gc at %ld>>\n", vts_next_GC_at);
}
- if (1) {
+ if (VG_(clo_verbosity) > 1) {
static UInt ctr = 0;
tl_assert(nTab > 0);
- VG_(printf)("libhb: VTS GC: #%u old size %lu live %lu (%2llu%%)\n",
+ VG_(message)(Vg_DebugMsg,
+ "libhb: VTS GC: #%u old size %lu live %lu (%2llu%%)",
ctr++, nTab, nLive, (100ULL * nLive) / nTab);
}
}
-Thread #1 is the program's root thread
-
Thread #3 was created
at 0x........: clone (in /...libc...)
by 0x........: ...
by 0x........: pthread_create@* (hg_intercepts.c:...)
by 0x........: main (hg03_inherit.c:46)
-Possible data race during write of size 4 at 0x........
+Thread #1 is the program's root thread
+
+Possible data race during write of size 4 at 0x........ by thread #3
at 0x........: t2 (hg03_inherit.c:28)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
by 0x........: ...
by 0x........: ...
- Old state: shared-readonly by threads #1, #3
- New state: shared-modified by threads #1, #3
- Reason: this thread, #3, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside shared[1],
- declared at hg03_inherit.c:11, in frame #0 of thread 3
+ This conflicts with a previous access by thread #1
+ at 0x........: main (hg03_inherit.c:60)
+ Location 0x........ is 0 bytes inside shared[1],
+ declared at hg03_inherit.c:11, in frame #0 of thread 3
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
-Thread #2 was created
+Thread #3 was created
at 0x........: clone (in /...libc...)
by 0x........: ...
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (hg_intercepts.c:...)
- by 0x........: main (hg04_race.c:19)
+ by 0x........: main (hg04_race.c:21)
-Thread #3 was created
+Thread #2 was created
at 0x........: clone (in /...libc...)
by 0x........: ...
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (hg_intercepts.c:...)
- by 0x........: main (hg04_race.c:21)
+ by 0x........: main (hg04_race.c:19)
-Possible data race during write of size 4 at 0x........
+Possible data race during read of size 4 at 0x........ by thread #3
+ at 0x........: th (hg04_race.c:10)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ This conflicts with a previous access by thread #2
at 0x........: th (hg04_race.c:10)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
by 0x........: ...
by 0x........: ...
- Old state: shared-readonly by threads #2, #3
- New state: shared-modified by threads #2, #3
- Reason: this thread, #3, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside local var "shared"
- declared at hg04_race.c:6, in frame #0 of thread 2
+ Location 0x........ is 0 bytes inside local var "shared"
+ declared at hg04_race.c:6, in frame #0 of thread 2
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
-Thread #2 was created
+Thread #3 was created
at 0x........: clone (in /...libc...)
by 0x........: ...
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (hg_intercepts.c:...)
- by 0x........: main (hg05_race2.c:27)
+ by 0x........: main (hg05_race2.c:29)
-Thread #3 was created
+Thread #2 was created
at 0x........: clone (in /...libc...)
by 0x........: ...
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (hg_intercepts.c:...)
- by 0x........: main (hg05_race2.c:29)
+ by 0x........: main (hg05_race2.c:27)
-Possible data race during write of size 4 at 0x........
+Possible data race during read of size 4 at 0x........ by thread #3
+ at 0x........: th (hg05_race2.c:17)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ This conflicts with a previous access by thread #2
at 0x........: th (hg05_race2.c:17)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
by 0x........: ...
by 0x........: ...
- Old state: shared-readonly by threads #2, #3
- New state: shared-modified by threads #2, #3
- Reason: this thread, #3, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
- declared at hg05_race2.c:24, in frame #4 of thread 1
+ Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
+ declared at hg05_race2.c:24, in frame #4 of thread 1
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
by 0x........: pthread_create@* (hg_intercepts.c:...)
by 0x........: main (tc01_simple_race.c:22)
-Possible data race during write of size 4 at 0x........
+Possible data race during read of size 4 at 0x........ by thread #1
at 0x........: main (tc01_simple_race.c:28)
- Old state: shared-readonly by threads #1, #2
- New state: shared-modified by threads #1, #2
- Reason: this thread, #1, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside global var "x"
- declared at tc01_simple_race.c:9
+ This conflicts with a previous access by thread #2
+ at 0x........: child_fn (tc01_simple_race.c:14)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ Location 0x........ is 0 bytes inside global var "x"
+ declared at tc01_simple_race.c:9
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Thread #1 is the program's root thread
-Thread #1 deallocated location 0x........ containing a locked lock
- at 0x........: free (vg_replace_malloc.c:...)
- by 0x........: main (tc04_free_lock.c:24)
- Lock at 0x........ was first observed
- at 0x........: pthread_mutex_init (hg_intercepts.c:...)
- by 0x........: main (tc04_free_lock.c:20)
+Thread #1: Exiting thread still holds 2 locks
+ at 0x........: _Exit (in /...libc...)
+ by 0x........: ...
+ by 0x........: (below main) (in /...libc...)
-Thread #1 deallocated location 0x........ containing a locked lock
- at 0x........: bar (tc04_free_lock.c:40)
- by 0x........: main (tc04_free_lock.c:26)
- Lock at 0x........ was first observed
- at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
- by 0x........: bar (tc04_free_lock.c:38)
- by 0x........: main (tc04_free_lock.c:26)
-
-Thread #1 deallocated location 0x........ containing a locked lock
- at 0x........: foo (tc04_free_lock.c:49)
- by 0x........: main (tc04_free_lock.c:27)
- Lock at 0x........ was first observed
- at 0x........: pthread_mutex_init (hg_intercepts.c:...)
- by 0x........: foo (tc04_free_lock.c:46)
- by 0x........: main (tc04_free_lock.c:27)
-
-Thread #1 deallocated location 0x........ containing a locked lock
- at 0x........: bar (tc04_free_lock.c:40)
- by 0x........: main (tc04_free_lock.c:28)
- Lock at 0x........ was first observed
- at 0x........: pthread_mutex_lock (hg_intercepts.c:...)
- by 0x........: bar (tc04_free_lock.c:38)
- by 0x........: main (tc04_free_lock.c:28)
-
-ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
+ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
by 0x........: pthread_create@* (hg_intercepts.c:...)
by 0x........: main (tc05_simple_race.c:27)
-Possible data race during write of size 4 at 0x........
+Possible data race during read of size 4 at 0x........ by thread #1
at 0x........: main (tc05_simple_race.c:33)
- Old state: shared-readonly by threads #1, #2
- New state: shared-modified by threads #1, #2
- Reason: this thread, #1, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside global var "y"
- declared at tc05_simple_race.c:10
+ This conflicts with a previous access by thread #2
+ at 0x........: child_fn (tc05_simple_race.c:19)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ Location 0x........ is 0 bytes inside global var "y"
+ declared at tc05_simple_race.c:10
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
#include <stdlib.h>
/* Simple test program, has two races. A happens-before detector can only
- ever detect one of them, though. */
+ ever detect one of them, though. XXX: apparently not so; Drd and H 3.4 detect both. */
int unprot1 = 0, unprot2 = 0, prot = 0;
pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
by 0x........: pthread_create@* (hg_intercepts.c:...)
by 0x........: main (tc06_two_races.c:26)
-Possible data race during write of size 4 at 0x........
+Possible data race during read of size 4 at 0x........ by thread #1
at 0x........: main (tc06_two_races.c:31)
- Old state: shared-readonly by threads #1, #2
- New state: shared-modified by threads #1, #2
- Reason: this thread, #1, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside global var "unprot1"
- declared at tc06_two_races.c:9
+ This conflicts with a previous access by thread #2
+ at 0x........: child_fn (tc06_two_races.c:14)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ Location 0x........ is 0 bytes inside global var "unprot1"
+ declared at tc06_two_races.c:9
-Possible data race during write of size 4 at 0x........
+Possible data race during read of size 4 at 0x........ by thread #1
at 0x........: main (tc06_two_races.c:35)
- Old state: shared-readonly by threads #1, #2
- New state: shared-modified by threads #1, #2
- Reason: this thread, #1, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside global var "unprot2"
- declared at tc06_two_races.c:9
+ This conflicts with a previous access by thread #2
+ at 0x........: child_fn (tc06_two_races.c:18)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ Location 0x........ is 0 bytes inside global var "unprot2"
+ declared at tc06_two_races.c:9
ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
{
int i;
for (i = 0; i < 5; i++)
- bytes[2*i + 0] ++;
+ bytes[2*i + 0] ++; /* child accesses: 0 2 4 6 8 */
return NULL;
}
/* Unprotected relative to child, but harmless, since different
bytes accessed */
for (i = 0; i < 5; i++)
- bytes[2*i + 1] ++;
+ bytes[2*i + 1] ++; /* accesses: 1 3 5 7 9 */
/* Unprotected relative to child, but harmful; same bytes */
for (i = 0; i < 3; i++)
- bytes[3*i + 1] ++;
+ bytes[3*i + 1] ++; /* accesses: 1 4(race!) 7 */
if (pthread_join(child, NULL)) {
perror("pthread join");
by 0x........: pthread_create@* (hg_intercepts.c:...)
by 0x........: main (tc16_byterace.c:22)
-Possible data race during write of size 1 at 0x........
+Possible data race during read of size 1 at 0x........ by thread #1
at 0x........: main (tc16_byterace.c:34)
- Old state: shared-readonly by threads #1, #2
- New state: shared-modified by threads #1, #2
- Reason: this thread, #1, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside bytes[4],
- a global variable declared at tc16_byterace.c:7
+ This conflicts with a previous access by thread #2
+ at 0x........: child_fn (tc16_byterace.c:13)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ Location 0x........ is 0 bytes inside bytes[4],
+ a global variable declared at tc16_byterace.c:7
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
/* This is really a test of semaphore handling
(sem_{init,destroy,post,wait}). Using semaphores a barrier
- function is created. Thrcheck does understand the barrier
- semantics implied by the barrier, as pieced together from
- happens-before relationships obtained from the component
- semaphores. However, it does falsely report one race. Ah well. */
+ function is created. Helgrind-3.3 (p.k.a Thrcheck) does understand
+ the barrier semantics implied by the barrier, as pieced together
+ from happens-before relationships obtained from the component
+ semaphores. However, it does falsely report one race. Ah well.
+ Helgrind-3.4 is pure h-b and so reports no races (yay!). */
/* This code is derived from
gcc-4.3-20071012/libgomp/config/posix/bar.c, which is
-Thread #2 was created
+Thread #3 was created
at 0x........: clone (in /...libc...)
by 0x........: ...
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (hg_intercepts.c:...)
by 0x........: main (tc21_pthonce.c:86)
-Thread #3 was created
+Thread #2 was created
at 0x........: clone (in /...libc...)
by 0x........: ...
by 0x........: pthread_create@GLIBC_ (in /lib/libpthread...)
by 0x........: pthread_create@* (hg_intercepts.c:...)
by 0x........: main (tc21_pthonce.c:86)
-Possible data race during write of size 4 at 0x........
+Possible data race during read of size 4 at 0x........ by thread #3
+ at 0x........: child (tc21_pthonce.c:74)
+ by 0x........: mythread_wrapper (hg_intercepts.c:...)
+ by 0x........: ...
+ by 0x........: ...
+ This conflicts with a previous access by thread #2
at 0x........: child (tc21_pthonce.c:74)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
by 0x........: ...
by 0x........: ...
- Old state: shared-readonly by threads #2, #3
- New state: shared-modified by threads #2, #3
- Reason: this thread, #3, holds no consistent locks
- Location 0x........ has never been protected by any lock
- Location 0x........ is 0 bytes inside local var "unprotected2"
- declared at tc21_pthonce.c:51, in frame #0 of thread 2
+ Location 0x........ is 0 bytes inside local var "unprotected2"
+ declared at tc21_pthonce.c:51, in frame #0 of thread 2
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)