|
From: <Joe...@pd...> - 2004-06-25 12:13:45
|
I have an signal handler to dump the current backtrace like in http://www.linuxjournal.com/article.php?sid=3D6391 described.=20 But with valgrind I get in the handler a memory fault while without = there is no fault. I just want to disable the handler when the program is running in = valgrind. So is there a way to detect this condition? Joerg |
|
From: Tom H. <th...@cy...> - 2004-06-25 13:03:05
|
In message <BE0...@ex...>
Jörg Richter <Joe...@pd...> wrote:
> I have an signal handler to dump the current backtrace like in
> http://www.linuxjournal.com/article.php?sid=6391 described.
We have something similar in our code.
> But with valgrind I get in the handler a memory fault while without
> there is no fault.
There's no particular reason why that should happen just because
you're running under valgrind. Are you sure your signal handler isn't
doing something naughty and just happening to get away with it
normally?
If you're writing that sort of signal handler you should be really
careful about what you're doing - try not to use things like malloc
for example as the heap may be corrupt when the handler runs.
It's also a good idea to have the handler install a new handler for
signals like SEGV and abort the backtrace if such a signal occurs as
the stack may be trashed and trying to follow it may trigger further
faults.
> I just want to disable the handler when the program is running in
> valgrind.
> So is there a way to detect this condition?
#include <valgrind/valgrind.h>
if (RUNNING_ON_VALGRIND)
{
...
}
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|