Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > ISO free tools to debug malloc/free bugs

Reply
Thread Tools

ISO free tools to debug malloc/free bugs

 
 
kj
Guest
Posts: n/a
 
      12-06-2004



For me, the hardest bugs to figure out have to do with malloc and/or
free, because such a bug usually manifests itself as a seg fault
happening at a place in the code that, AFAICT, can be totally
unrelated to the code responsible for the bug.

I know that there are commercial tools to help with such bugs, but
I work at an academic lab on a shoestring, so we make do with open
source tools unless it is absolutely unavoidable to spring for the
non-free stuff.

Are there any free tools to help tracking such bugs? FWIW, I use
gcc-2.95.

Thanks!

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
 
Reply With Quote
 
 
 
 
Daniel Vallstrom
Guest
Posts: n/a
 
      12-06-2004
kj wrote:
> For me, the hardest bugs to figure out have to do with malloc and/or
> free, because such a bug usually manifests itself as a seg fault
> happening at a place in the code that, AFAICT, can be totally
> unrelated to the code responsible for the bug.
>
> I know that there are commercial tools to help with such bugs, but
> I work at an academic lab on a shoestring, so we make do with open
> source tools unless it is absolutely unavoidable to spring for the
> non-free stuff.
>
> Are there any free tools to help tracking such bugs?


Have a look at the excellent Valgrind. It's doubly free too.

Daniel Vallstrom
 
Reply With Quote
 
 
 
 
Chris Croughton
Guest
Posts: n/a
 
      12-06-2004
On Mon, 6 Dec 2004 14:21:51 +0000 (UTC), kj
<(E-Mail Removed)> wrote:

> For me, the hardest bugs to figure out have to do with malloc and/or
> free, because such a bug usually manifests itself as a seg fault
> happening at a place in the code that, AFAICT, can be totally
> unrelated to the code responsible for the bug.
>
> I know that there are commercial tools to help with such bugs, but
> I work at an academic lab on a shoestring, so we make do with open
> source tools unless it is absolutely unavoidable to spring for the
> non-free stuff.
>
> Are there any free tools to help tracking such bugs? FWIW, I use
> gcc-2.95.


Yes, dmalloc (http://dmalloc.com/). Some Linux systems have it already
compiled as a package (Debian, for instance).

The author does ask (but doesn't insist) that it you find it useful you
make a donation (the actual software is released under a very permissive
licence). I found it useful (incredibly so; after a week of trying to
find a problem which caused free() to crash -- it was obviously
something writing somewhere it shouldn't, but I couldn't see what -- I
used dmalloc and it trapped the area being overwritten, I looked at the
bad values in the guard area and it was obvious what did it)...

Chris C
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      12-06-2004
kj wrote:
>
> For me, the hardest bugs to figure out have to do with malloc and/or
> free, because such a bug usually manifests itself as a seg fault
> happening at a place in the code that, AFAICT, can be totally
> unrelated to the code responsible for the bug.
>
> I know that there are commercial tools to help with such bugs, but
> I work at an academic lab on a shoestring, so we make do with open
> source tools unless it is absolutely unavoidable to spring for the
> non-free stuff.
>
> Are there any free tools to help tracking such bugs? FWIW, I use
> gcc-2.95.


If you use DJGPP (which you can under most editions of Windows or
MsDos) you can use my nmalloc package (which was written for DJGPP,
but has not yet been incorporated). It includes a debugging
package, and info documentation entries for it all. You can find
it at:

<http://cbfalconer.home.att.net/download/nmalloc.zip>

Ignore the memalign garbage in the package, that is incomplete. It
might function with other systems than DJGPP, but that is a
separate matter, and no guarantees.

--
Chuck F ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


 
Reply With Quote
 
Jonathan Bartlett
Guest
Posts: n/a
 
      12-06-2004
kj wrote:
> For me, the hardest bugs to figure out have to do with malloc and/or
> free, because such a bug usually manifests itself as a seg fault
> happening at a place in the code that, AFAICT, can be totally
> unrelated to the code responsible for the bug.
>


You can use a garbage collector like Boehm. It also does malloc debugging.

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

Also, you might be interested in my DeveloperWorks article on memory
management:

http://www-106.ibm.com/developerwork...rary/l-memory/

It has a lot of interesting ideas and good resources.

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free tips and tricks for Scripts,HP Open View products, ITIL, ISO 27001, ISO 2000 etc.. ashlyak@gmail.com Computer Support 2 08-08-2007 01:05 AM
Bugs and Bugs...get rid of them Jason Computer Security 1 01-31-2006 10:47 PM
Still use 'ruby-bugs' for Ruby bugs? Josef 'Jupp' Schugt Ruby 2 11-04-2004 10:10 PM



Advertisments