From: Bart Van Assche Date: Sun, 15 Jan 2012 19:13:35 +0000 (+0000) Subject: drd: Set up red zone before the first instruction of a thread is run. X-Git-Tag: svn/VALGRIND_3_8_0~521 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0515a0bb85e544fdfb0f7db2ee86ab3a57d6250b;p=thirdparty%2Fvalgrind.git drd: Set up red zone before the first instruction of a thread is run. 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::set(counter*, AtomicInt32*) (annotate_smart_pointer.cpp:239) ==18170== by 0x401778: smart_ptr::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 --- diff --git a/drd/drd_main.c b/drd/drd_main.c index 5889f4ca89..a48dc37c61 100644 --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -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);