ARRRG segfault

Kevin Buettner plug-discuss@lists.plug.phoenix.az.us
Thu, 28 Mar 2002 18:17:14 -0700


On Mar 28,  5:27pm, der.hans wrote:

> Am 28. Mar, 2002 schwätzte John (EBo) David so:
> 
> > are there any freely distibuted tools availible like purify, etc.
> > availible on Linux?
> 
> Don't know what purify is, but I presume you're looking for a memory
> debugger.
> 
> $ apt-cache search memory | grep debug
> fda - C malloc debug library
> kernel-patch-2.2.13-kdb - Builtin kernel debugger.
> task-debug - Debugging of C, C++, Objective C and friends
> ccmalloc - A memory profiler/debugger
> crash - A kernel debugging utility, allowing gdb like syntax.
> electric-fence - A malloc(3) debugger
> gccchecker - Memory access debugger for C language development
> mpatrol - A powerful library for debugging memory allocations
> kernel-patch-kdb - Builtin kernel debugger.
> 
> And this URL was pointed out on a mailing list last week:
> 
> http://developer.kde.org/~sewardj/

This last one is valgrind.  It's really quite impressive.  If the link
above doesn't work, try:

    http://www.muraroa.demon.co.uk/

(The kde link worked just now when I tried it, but I couldn't get it
to work earlier in the week.)

I've successfully used dmalloc in the past to track down a number of
memory allocation errors.  dmalloc is available from:

    http://dmalloc.com/

I've also used Electric Fence in the past to find memory overruns.  The
first time I used it, I was quite excited about it because it found a
bug that would've taken me a very long time to find otherwise.  But,
more recently, it's not worked very well for me.

I'd suggest trying valgrind first and dmalloc second.  The cool thing
about valgrind is that it'll work without recompiling your program. 
The problem with it is that it'll only run on x86 and is sensitive to
shared library and kernel versions.  Also, there are some limitations
about the types of programs that it will work on.  E.g, it won't work
on multi-threaded programs.

dmalloc works on many different platforms, but requires a recompile of
your application.

Finally, if an application is segfaulting, one of the first things you
should try is to run it under GDB or use GDB to debug the core file.
Sometimes, the answer is fairly obvious without the need for a memory
debugging tool.

Kevin