memory debugger(s) for linux

Status
Not open for further replies.

angst

Smack-Fu Master, in training
51
I'm looking for a powerful memory debugger for Linux ( open source or commercial ). The prereqs are fairly simple ...

- must be able to cope with C and C++
- must be able to detects leaks
- must be able to detect memory errors ( example below )
- must be fast enough to debug appliactions with user interface ( basically must be responsive enough to click through the menus/buttons/etc )

the following are the key memory errors that are pretty much a must as far as detection goes. Naming convension is up for grabs, all I care about is a report with a line number and some indication of error type

Code:
 int main( )
{ 
  /* leak with free */
  char* fc = (char*)malloc(32);
  
  /* leak with new */
  char* nc = new char[64];
  
  /* free mismatched memory */
  char* nm = new char[64];
  delete nm;
  
  /* try again, this time with free */
  nm = new char[64];
  free(nm);
  
  /* leak some more */
  int* i = new int[16];
  int* j = new int;
  int* k = new int[16];
  delete j;
  
  /* free memory write */
  *j = 5;

  /* array bounds write */
  i[16] = 10;

  /* array bounds read */
  k[0] = i[16];
}

so far I've tried ..
- mpatrol, which is fantastic when it comes to the detection features, but horribly slow with Motif/Xt
- Great Circle, which has a nice web based interface and is quite speedy, but failed to find any errors except for the leaks (??)

** some commonly used OS debuggers like dmalloc/mprof are out of the question since they can't debug C++ code.

Anyway, if anyone has any suggestions, please free to post them here
 

Don

Ars Tribunus Militum
2,673
Commercial:

Geodesic Analyzer and Great Circle
http://www.geodesic.com/solutions/solutions_linux.html

Insure++
http://www.parasoft.com/jsp/home.jsp



Non-Commerical:

ccmalloc
http://www.inf.ethz.ch/personal/biere/projects/ccm alloc/

Valgrind
http://developer.kde.org/~sewardj/

Boehm Collector
http://www.hpl.hp.com/personal/Hans_Boehm/gc/

Parallel Collector on Message Passing Environment
http://www.yl.is.s.u-tokyo.ac.jp/gc/dgc/

Mpatrol
http://www.cbmamiga.demon.co.uk/mpatrol/

MProf
http://people.redhat.com/otaylor/memprof/
 

angst

Smack-Fu Master, in training
51
ok, yamd looks pretty damn cool, however I can't get it to print the offending line number(s). It prints the backtrace with the offsets and the v address, but the README mentions printouts of corresponding line sumbers with the source ( and yes the program is compiled with -g flag )

here's my example program

Code:
int main( )
{
  int* j = new int;
  delete j;
  *j = 0;
}

and here's yamd output run with run-yamd -l 2 ./a.out on RH 7.2 with glibc = 2.2.4 and gcc = 2.95.3

Code:
default_alignment = 1
min_log_level = 2
repair_corrupted = 0
die_on_corrupted = 1
check_front = 0

ERROR: Crash
        ./a.out(main+0x2a)[0x80486aa]
        /lib/i686/libc.so.6(__libc_start_main+0x93)[0x400bf507]
        ./a.out(__register_frame_info+0x35)[0x80485c1]
Tried to write address 0x40025ffc
Seems to be part of this block:
Address 0x40025ffc, size 4
Allocated by malloc at
        /lib/i686/libc.so.6(malloc+0x2d)[0x40122f8d]
        /usr/local/lib/libstdc++-libc6.2-2.1.so.3(__builtin_new+0x29)[0x400605c9]
        ./a.out(main+0x10)[0x8048690]
        /lib/i686/libc.so.6(__libc_start_main+0x93)[0x400bf507]
        ./a.out(__register_frame_info+0x35)[0x80485c1]
Freed by free at
        /lib/i686/libc.so.6(__libc_free+0x2d)[0x40123b6d]
        /usr/local/lib/libstdc++-libc6.2-2.1.so.3(__builtin_delete+0x24)[0x40060524]
        ./a.out(main+0x24)[0x80486a4]
        /lib/i686/libc.so.6(__libc_start_main+0x93)[0x400bf507]
        ./a.out(__register_frame_info+0x35)[0x80485c1]
Address in question is at offset 0 (in bounds)
 

dereferenced

Ars Scholae Palatinae
706
Ok, It's been a while but'¦

yamd-gcc -g foo.c -o foo
run-yamd -o foo.raw ./foo
do-syms ./foo <foo.raw >foo.log

If that doesn't work then (wild guess) I would suspect an incompatible version of binutils, and by that I mean the version you have may be too new for yamd. yamd hasn't been updated in a while, you may want too look into another, newer, package like njamd maybe.

If yamd doesn't work out then sorry for the bum pointer. Last time I used it, admittedly a while ago, I recall that it worked well (found some leaks, grrr), but things change.

Regardless, Good luck
 

angst

Smack-Fu Master, in training
51
yeah, it's a do-syms problem ( addr2line from binutils returns garbage ), but my main concern right now is the speed, since some of the Motif based programs of mine do 10000+ mallocs/new/new[] before even the main window appears. I'll add some hooks to suppress calls for vallocs originating from X11 libs (as well as some other standard libraries m/c/rt....). yamd also doesn't distinguish between C and C++ calls, so already modified source to recognize calls to new, new[], delete, delete[].
 
Status
Not open for further replies.