Re: Program crashes - debugging suggestions?
From: boa (root_at_localhost.com)
Date: Tue, 29 Jun 2004 06:18:27 GMT
> Hi, I was hoping to get some suggestions on debugging a multi-threaded Linux
> program that crashes about every 10-12 hours. The program coordinates the
> behaviour between several (about 4)attached devices (serial and ethernet).
> There is generally one thread for each attached device. Unfortunately when
> it crashes the threads stop responding one-by-one, no seg fault or other
> obvious error occurs, making it very hard to pin down. What I suspect is
> happening is one thread is gradually overwriting memory and it crashes as
> soon as the memory being overwritten is in use by another thread. It
> currently has a 4k guard between threads.
> Does anyone have any suggestions for how to figure out which code is the
> source of the problem? I've inspected the most likely areas but haven't
> been successful in fixing it. Any techniques using gdb/ddd, or other tools?
> If it generated a seg fault it would be easy......
> Thanks in advance for any help, this is really driving me nuts!
Have you tried valgrind?
From its homepage at http://valgrind.kde.org/
Valgrind is a GPL'd system for debugging and profiling x86-Linux
programs. With the tools that come with Valgrind, you can automatically
detect many memory management and threading bugs, avoiding hours of
frustrating bug-hunting, making your programs more stable. You can also
perform detailed profiling, to speed up and reduce memory use of your
The Valgrind distribution includes five tools: two memory error
detectors, a thread error detector, a cache profiler and a heap
profiler. Several other tools have been built with Valgrind.