From: Julian Seward Date: Sat, 1 Dec 2007 02:09:50 +0000 (+0000) Subject: Only pass valid ThreadIDs to VG_(record_ExeContext). (Bart Van Assche) X-Git-Tag: svn/VALGRIND_3_3_0~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fbe42bfcaacf333cd8f5b830ed83926b328021f;p=thirdparty%2Fvalgrind.git Only pass valid ThreadIDs to VG_(record_ExeContext). (Bart Van Assche) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7261 --- diff --git a/exp-drd/TODO.txt b/exp-drd/TODO.txt index cbe891f33d..3566e8c6c6 100644 --- a/exp-drd/TODO.txt +++ b/exp-drd/TODO.txt @@ -4,6 +4,7 @@ Last updated February 22, 2006 Data-race detection algorithm ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- Implement glibc version detection in drd_main.c. - Implement segment merging, such that the number of segments per thread remains limited even when there is no synchronization between threads. - Find out why a race is reported on std::string::string(std::string const&) diff --git a/exp-drd/drd_preloaded.c b/exp-drd/drd_preloaded.c index 0a0b30035b..a0c6a1a84e 100644 --- a/exp-drd/drd_preloaded.c +++ b/exp-drd/drd_preloaded.c @@ -198,10 +198,6 @@ PTH_FUNC(int, pthreadZucreateZAZa, // pthread_create@* { assert(0); } -#if 0 - printf("[%ld] Requested detach state for new thread: %d\n", - pthread_self(), vgargs.detachstate); -#endif } assert(vgargs.detachstate == PTHREAD_CREATE_JOINABLE || vgargs.detachstate == PTHREAD_CREATE_DETACHED); @@ -224,9 +220,12 @@ PTH_FUNC(int, pthreadZucreateZAZa, // pthread_create@* // in this file (vg_preloaded.c) would be called instead of those in // libpthread.so. This loop is necessary because vgargs is allocated on the // stack, and the created thread reads it. - while (! vgargs.wrapper_started) + if (ret == 0) { - sched_yield(); + while (! vgargs.wrapper_started) + { + sched_yield(); + } } #endif return ret; diff --git a/exp-drd/drd_segment.c b/exp-drd/drd_segment.c index cb4b979ce9..a83a4148f0 100644 --- a/exp-drd/drd_segment.c +++ b/exp-drd/drd_segment.c @@ -23,15 +23,16 @@ */ +#include "drd_error.h" +#include "drd_segment.h" +#include "drd_thread.h" #include "pub_tool_basics.h" // Addr, SizeT #include "pub_tool_errormgr.h" // VG_(unique_error)() #include "pub_tool_libcassert.h" // tl_assert() #include "pub_tool_libcbase.h" // VG_(strlen)() #include "pub_tool_libcprint.h" // VG_(printf)() #include "pub_tool_mallocfree.h" // VG_(malloc)(), VG_(free)() -#include "drd_error.h" -#include "drd_segment.h" -#include "drd_thread.h" +#include "pub_tool_threadstate.h" // VG_INVALID_THREADID // Local variables. @@ -52,6 +53,7 @@ void sg_init(Segment* const sg, DrdThreadId const created) { Segment* creator_sg; + ThreadId vg_created = DrdThreadIdToVgThreadId(created); tl_assert(sg); tl_assert(creator == DRD_INVALID_THREADID || IsValidDrdThreadId(creator)); @@ -62,7 +64,10 @@ void sg_init(Segment* const sg, sg->next = 0; sg->prev = 0; - sg->stacktrace = VG_(record_ExeContext)(created, 0); + if (vg_created != VG_INVALID_THREADID) + sg->stacktrace = VG_(record_ExeContext)(vg_created, 0); + else + sg->stacktrace = 0; if (creator_sg) vc_copy(&sg->vc, &creator_sg->vc);