XForms: More memory debugging tools

Steve Lamont (spl@szechuan.ucsd.edu)
Thu, 17 Sep 98 18:15:25 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

There's another debugging tool which has a good reputation called
Electric Fence, developed by Bruce Perens of Pixar and posted to
USENET several years ago.

It works a little differently than dbmalloc and may be useful in
finding memory overruns. The idea of the tool is pretty simple: when
you do a malloc() or other memory allocation, it mmap()s one or more
pages of virtual memory and aligns your request such that the last
byte (or at least the last memory allocation unit) is on a page
boundary.

Writing (or reading) off the end of an allocation immediately Seg
Faults (or results in a Bus Error -- this depends on architecture).

This makes off-the-end-of-memory errors easy to find.

It is available on the net in one of the comp.sources archives.
Search for `efence' and you should find it.

For convenience, I've also placed it on my FTP server:

ftp://ncmir.ucsd.edu/pub/electric_fence/ElectricFence.shar

This is the file as posted to comp.sources. It is a shell archive
file. You should create a directory and unpack it in that directory
by

cd efence
/bin/sh ElectricFence.shar

Sun users will probably want to edit the Makefile to change the
PAGE_PROTECTION_VIOLATED_SIGNAL flag from SIGBUS to SIGSEGV and you
may need to play with compiler flags a little.

Like all memory debug tools, you should only use it for debugging and
not for production code -- it will make your programs *huge* and
*slow*. Also like all memory debug tools, it has its limits.

I take no credit or responsibility for the code -- it works nicely but
no guarantees. If your cat suddenly turns vampire and devours the
guppies while you run the library, it ain't my problem.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/