]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd: Set up red zone before the first instruction of a thread is run.
authorBart Van Assche <bvanassche@acm.org>
Sun, 15 Jan 2012 19:13:35 +0000 (19:13 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 15 Jan 2012 19:13:35 +0000 (19:13 +0000)
Avoids that DRD sporadically reports mysterious false positive conflicting accesses on
amd64 like e.g. the following:

$ ./vg-in-place --fair-sched=yes --tool=drd --read-var-info=yes --check-stack-var=yes --show-confl-seg=no drd/tests/annotate_smart_pointer 50 50
==18170== drd, a thread error detector
==18170== Copyright (C) 2006-2011, and GNU GPL'd, by Bart Van Assche.
==18170== Using Valgrind-3.8.0.SVN and LibVEX; rerun with -h for copyright info
==18170== Command: ./annotate_smart_pointer 50 50
==18170==
==18170== Conflicting store by thread 1 at 0x7fefff8a0 size 8
==18170==    at 0x400FCE: AnnotateCondVarSignal (unified_annotations.h:32)
==18170== Allocation context: unknown.
==18170==
==18170== Conflicting load by thread 1 at 0x7fefff8a0 size 8
==18170==    at 0x400FDD: AnnotateCondVarSignal (unified_annotations.h:34)
==18170==    by 0x401071: U_AnnotateHappensBefore (unified_annotations.h:46)
==18170==    by 0x4018DD: smart_ptr<counter>::set(counter*, AtomicInt32*) (annotate_smart_pointer.cpp:239)
==18170==    by 0x401778: smart_ptr<counter>::operator=(counter*) (annotate_smart_pointer.cpp:208)
==18170==    by 0x401377: main (annotate_smart_pointer.cpp:326)
==18170== Allocation context: unknown.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12332

drd/drd_main.c

index 5889f4ca8922e6d283dee19b9e9a86a8f44ec02e..a48dc37c6110e9b908c91060883127bff5844464 100644 (file)
@@ -602,10 +602,16 @@ static
 void drd_post_thread_create(const ThreadId vg_created)
 {
    DrdThreadId drd_created;
+   Addr stack_max;
 
    tl_assert(vg_created != VG_INVALID_THREADID);
 
    drd_created = DRD_(thread_post_create)(vg_created);
+
+   /* Set up red zone before the code in glibc's clone.S is run. */
+   stack_max = DRD_(thread_get_stack_max)(drd_created);
+   drd_start_using_mem_stack2(drd_created, stack_max, 0);
+
    if (DRD_(thread_get_trace_fork_join)())
    {
       DRD_(trace_msg)("drd_post_thread_create created = %d", drd_created);