Anders Johansson wrote:
On Tuesday 30 November 2004 16:14, Kwasneski, Christopher D (Northrop Grumman) wrote:
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.
valgrind is an insanely useful program for debugging memory matters. Have a look at that as well
Indeed it is. I downloaded both ElectricFence & valgrind. EF (apparently) requires you to link in a different malloc library (theirs) to debug, while valgrind runs underneath the whole shebang with the stock malloc library. I like the 2nd approach better. I had to get the newer version, mentioned in a later post, but it worked wonders. I found around a dozen places where I was doubly (or more :-) ) freeing the same pointer, some separated by routine boundaries (& thus a bit tougher to find). VERY NICE CODE !!! I heartily recommend it to anyone with malloc/free problems. Thanks for the pointer :-).