From eichin@ATHENA.MIT.EDU Tue Nov  6 20:37:44 1990
SUM: Mark W. Eichin <eichin>->marc@MIT.EDU,watchmakers, sipb
SUB: Re: debugging malloc
Received: by E40-PO.MIT.EDU (5.45/4.7) id AA28246; Tue, 6 Nov 90 18:48:42 EST
Received: from E40-008-8.MIT.EDU by ATHENA.MIT.EDU with SMTP
	id AA07915; Tue, 6 Nov 90 18:47:30 EST
Received: by E40-008-8.MIT.EDU (5.61/4.7) id AA12449; Tue, 6 Nov 90 18:47:27 -0500
Date: Tue, 6 Nov 90 18:47:27 -0500
From: Mark W. Eichin <eichin@ATHENA.MIT.EDU>
Message-Id: <9011062347.AA12449@E40-008-8.MIT.EDU>
To: marc@MIT.EDU
Cc: watchmakers@ATHENA.MIT.EDU, sipb@ATHENA.MIT.EDU
In-Reply-To: Marc Horowitz <marc@ATHENA.MIT.EDU> Tue, 06 Nov 90 06:02:20 EST <9011061102.AA17346@BILL-THE-CAT.MIT.EDU>
Subject: Re: debugging malloc


   SUM: Marc Horowitz <marc>->watchmakers,sipb
   SUB: debugging malloc

   I need a debugging malloc.  Specifically, something which will do
   bounds checking on each call to malloc and free.  Right now, g++ on
   the vax is dumping code in malloc.  Does anybody have any experience
   with this, or a debugging malloc I can try using?  This is for a
   problem set, so I'd appreciate any fast response.  Thanks in advance.

		   Marc


attach eichin; /mit/eichin/projects/malloc/malloc.c (.o file there is
for the vax, I think.) If you build it, make sure scribblecheck is
#def'd. After every malloc and free it checks to make sure nothing in
the space after or before the block in question has been trashed; it
also detects multiple free's and other types of corruption. It calls
botch with a string argument which describes the problem, though the
source is generally the best commentary on why it botched.
	If you define "parent" (I think, check the code) it will log
what caller freed or malloced the block most recently (this works on
the vax; I *may* have gotten it working on the RT, but I doubt it. It
involves walking up the stack to find the return address.)
	It's based on an old gnuemacs malloc; I put this together for
Foundation when I was working for wdc. Many people have used it over
the years (I think, there's a previous entry in Lore about it too...)
						_Mark_


