]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Callgrind: fix bug 217849: Switch to running thread in CLG_(post_signal)
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Thu, 10 Dec 2009 19:26:32 +0000 (19:26 +0000)
committerJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Thu, 10 Dec 2009 19:26:32 +0000 (19:26 +0000)
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

index 9334667ea74d0f267ca4d7381d17478f0042901a..ea5c189e950b4de3cef67fad9245f35c91a1478a 100644 (file)
@@ -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.