RE: [suse-programming-e] porting problems ....
by Kwasneski, Christopher D (Northrop Grumman)
> -----Original Message-----
> From: William A. Mahaffey III [mailto:wam@HiWAAY.net]
> Sent: Tuesday, November 30, 2004 7:54 AM
> To: Suse Programming List
> Subject: [suse-programming-e] porting problems ....
>
>
> .... I am trying to port some code (a Motif
> CAD/Grid-generator) from SGI to my SuSE 8.2 Linux box.
> Everything is coming fairly smoothly (actually DAMN smooth),
> except for 1 thing. The code is mostly C, with some
> leaf-FORTRAN. I use malloc/realloc & free to allocate & free
> mamory. I have found several places where I was calling free
> repeatedly with the same pointer (slides by on SGI, bombs
> under Linux) & corrected all of them so far. I have fixed all
> the simple/silly stuff (I think) & now need to go a bit
> deeper. I tried activating the documented memory debugging
> using '#define MALLOC_CHECK_' in my program main, but I get
> no diagnostics or core dump, just execution which gets to a
> specific line & hangs. I have also tried the mtrace facility,
> but just get mention of 3
> hex addresses where memory is free'd that wasn't alloc'd. I
> think I am
> screwing something else up earlier, but can't get a core dump or any
> diagnostics to help me out. SGI has a nice & very handy
> memory debugger
> (malloc (3X)) which can be compiled in & activated at runtime
> as needed,
> ignored otherwise. I haven't found any such thing (yet) under
> Linux. My
> question is how do I get Linux to either dump core or give me some
> diagnostics (at every call to malloc or free, like SGI ;-) ) so I can
> find my more subtle screwups & fix them ? TIA
You could try electric fence (probably on your distro. Try 'man efence'),
NJAMD (Not Just Another Malloc Debugger), or google for something similar.
Also, compiling it with the -g option (Assuming gcc), and run it through
gdb.
-Chris Kwasneski
Software Engineer
YPG, AZ