[comp.lang.c] Request - malloc/free wrappers to aid debugging

dg3s+@andrew.cmu.edu (David Gentzel) (01/20/90)

I vaugely recall reading a message (or messages) on this list some time ago
about a set of wrapper functions/macros for malloc/free to aid debugging.
They (if my memory serves) kept track of malloced/freed memory and allowed
you to detect such common snafus as multiple frees and memory leaks.

If anyone knows of such a package, please let me know.  It would be a valuable
addition to my debugging war chest.

						Dave Gentzel
						dg3s@andrew.cmu.edu

state@unc.cs.unc.edu (Andrei State) (01/21/90)

In article <gZhzPmi00WB8N9WoYF@andrew.cmu.edu>, dg3s+@andrew.cmu.edu (David Gentzel) writes:
> I vaugely recall reading a message (or messages) on this list some time ago
> about a set of wrapper functions/macros for malloc/free to aid debugging.
> They (if my memory serves) kept track of malloced/freed memory and allowed
> you to detect such common snafus as multiple frees and memory leaks.
> 
> If anyone knows of such a package, please let me know.  It would be a valuable
> addition to my debugging war chest.

Have a look at Dr. Dobb's Journal #159 (WINTER 1989 special issue), which
contains an article and source for "C Customized Memory Allocators".
_________________________________________________________________________
Andrei State                       alias                 state@cs.unc.edu
more movie buff than graduate student at the University of North Carolina

lss@babcock.cerc.wvu.wvnet.edu (Linda S. Saus) (01/22/90)

From article <gZhzPmi00WB8N9WoYF@andrew.cmu.edu>, by dg3s+@andrew.cmu.edu (David Gentzel):
> I vaugely recall reading a message (or messages) on this list some time ago
> about a set of wrapper functions/macros for malloc/free to aid debugging.
> They (if my memory serves) kept track of malloced/freed memory and allowed
> you to detect such common snafus as multiple frees and memory leaks.
> 
On SUN systems, the following is available:  See man pages for free to
get complete details.

DIAGNOSTICS
     More detailed diagnostics can be made available to  programs
     using  malloc, calloc, realloc, valloc, memalign, cfree, and
     free, by including a special relocatable object file at link
     time  (see FILES). This file also provides routines for con-
     trol of error handling  and  diagnosis,  as  defined  below.
     Note:  these  routines  are  not  defined  in  the  standard
     library.
             
FILES
     /usr/lib/debug/malloc.o  diagnostic  versions  of   malloc()
                              routines.
      

msb@sq.sq.com (Mark Brader) (01/24/90)

> I vaguely recall reading a message (or messages) on this list some time ago
> about a set of wrapper functions/macros for malloc/free to aid debugging.

This could be referring to malloctrace/mallck, which appeared in, um,
comp.sources.unix in October or November of 1988, and is available from
the archives of that group.  However, before you gleefully go retrieving
it from there, read this excerpt from the OVERALL_README file:

#  UNPORTABILITY CAVEATS -
#  
#    The tracing depends on being able to dump one's call stack.  This is
#  done by code in the file write_trace.c.  It works on our Sun running SunOS
#  3.0 or 3.2, but is likely to need rewriting on your machine!
#    There are two other things that work on our Sun but aren't portable:
#  the types "char *", "long", and "unsigned" seem to be inter-assigned
#  carelessly (I don't have time to delint this, either); and the BSDish
#  library function bcopy() is used.
#    Use at your own risk.
#  
#  Mark Brader, SoftQuad Inc., Toronto, August 25, 1988
#  { uunet!attcan | linus | decvax | watmath | pyramid } !utzoo!sq!msb
#  msb@sq.com		decwrl!utcsri!sq!msb

No, we haven't fixed these limitations since then.

Mark Brader, Toronto	    "If you feel [that Doug Gwyn] has a bad attitude,
utzoo!sq!msb, msb@sq.com     then use lint (or Chris Torek...)" -- Joe English