From 5384a19545a9c52b401eb1b26f2f719e6e6ffca7 Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Thu, 10 Dec 2009 19:26:32 +0000 Subject: [PATCH] Callgrind: fix bug 217849: Switch to running thread in CLG_(post_signal) If instrumentation is switched off on multithreaded code, multiple signals in a row handled by different threads could confuse callgrind. Callgrind assumed that in post_signal, it has the correct understanding of the currently running thread. This is not always correct. Really switch to running thread. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10966 --- callgrind/threads.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/callgrind/threads.c b/callgrind/threads.c index 9334667ea7..ea5c189e95 100644 --- a/callgrind/threads.c +++ b/callgrind/threads.c @@ -203,7 +203,7 @@ void CLG_(pre_signal)(ThreadId tid, Int sigNum, Bool alt_stack) tid, sigNum, alt_stack ? "yes":"no"); /* switch to the thread the handler runs in */ - CLG_(run_thread)(tid); + CLG_(switch_thread)(tid); /* save current execution state */ exec_state_save(); @@ -243,7 +243,8 @@ void CLG_(post_signal)(ThreadId tid, Int sigNum) CLG_DEBUG(0, ">> post_signal(TID %d, sig %d)\n", tid, sigNum); - CLG_ASSERT(tid == CLG_(current_tid)); + /* thread switching potentially needed, eg. with instrumentation off */ + CLG_(switch_thread)(tid); CLG_ASSERT(sigNum == CLG_(current_state).sig); /* Unwind call stack of this signal handler. -- 2.47.2