|
From: Martin H. <mar...@ci...> - 2011-08-18 13:12:59
|
Hi all, is it possible to make Helgrind print out stack trace for all threads at a given moment? I am debugging a quite complex program (~20 threads) and this would really help me finding the origins of a deadlock which occurs when running under Helgrind only (does not occur under gdb, not even under Memcheck). Thanks, Martin Heller |
|
From: Julian S. <js...@ac...> - 2011-08-18 15:03:40
|
On Thursday, August 18, 2011, Martin Heller wrote: > Hi all, > > is it possible to make Helgrind print out stack trace for all threads at > a given moment? > I am debugging a quite complex program (~20 threads) and this would > really help me finding the origins of a deadlock which occurs when > running under Helgrind only (does not occur under gdb, not even under > Memcheck). No, not really. Sure, it "knows" the stacks of all the threads, but the problem is that Valgrind runs exactly 1 thread for each thread in the original program, so there are no other threads around to "observe" that the system has deadlocked and print the thread stacks. Do the race reports and lock order violation reports help you figure out where the deadlock is? btw, if you are using Helgrind, you might want to try the svn trunk version. It is much improved from the 3.6.x version, in terms of speed, memory use and error messages. J |
|
From: Martin H. <mar...@ci...> - 2011-08-18 15:53:01
|
On 08/18/2011 05:00 PM, Julian Seward wrote: > No, not really. Sure, it "knows" the stacks of all the threads, > but the problem is that Valgrind runs exactly 1 thread for each > thread in the original program, so there are no other threads around > to "observe" that the system has deadlocked and print the thread > stacks. Thanks for the answer. In the meantime I have found a partial solution to this problem. I set ulimit -c ulimited run my program under helgrind and then kill it with SIGABRT when it hangs. Using gdb I can then get the stack trace from the vgcore.xxxx file generated. Still it would be a nice feature if Valgrind could just print the stack trace without quitting, for example after being sent SIGUSR signal. > Do the race reports and lock order violation reports help you figure > out where the deadlock is? They do not, there is just one data race (which should be harmless) reported before the deadlock. >From the stack trace I have found out that the deadlock is not due to lock order violation but that all threads are waiting for a condition variable signal which never comes. > btw, if you are using Helgrind, you might want to try the svn trunk > version. It is much improved from the 3.6.x version, in terms of > speed, memory use and error messages. I am already using the svn trunk version. I have installed it after encountering a crash which I described in http://sourceforge.net/mailarchive/message.php?msg_id=27866368 Unfortunately I am far from being able to create a small program to reproduce the crash. Martin Heller |
|
From: WAROQUIERS P. <phi...@eu...> - 2011-08-30 12:39:20
|
>Thanks for the answer. In the meantime I have found a partial solution >to this problem. I set >ulimit -c ulimited >run my program under helgrind and then kill it with SIGABRT when it >hangs. Using gdb I can then get the stack trace from the vgcore.xxxx >file generated. >Still it would be a nice feature if Valgrind could just print the stack >trace without quitting, for example after being sent SIGUSR signal. If you use a recent 3.7.0 svn version, you can use gdb to interactively connect at any time to the process running under Valgrind (as Valgrind now has an integrated gdbserver). You can then put breakpoints, "continue", and then use the normal gdb commands to look at the threads. E.g. to have a stack trace of all threads, you can do: (gdb) thread apply all bt or (to have all the local variables) (gdb) thread apply all bt full The interactive gdb usage might help you to understand what is going wrong when running under Valgrind. Alternatively, a patch (not reviewed/not checked in yet) is attached to bug http://bugs.kde.org/show_bug.cgi?id=279212 With this patch, from a shell, you can use the command vgdb v.info scheduler to have valgrind scheduler unwinder printing a stack trace for each thread. (this patch is to be applied on a 3.7.0 svn). Philippe |