Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site cca.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!cca!g-rh From: g-rh@cca.UUCP (Richard Harter) Newsgroups: net.lang.c,net.lang.c++ Subject: Re: oops, corrupted memory again! Message-ID: <7595@cca.UUCP> Date: Wed, 30-Apr-86 02:54:20 EDT Article-I.D.: cca.7595 Posted: Wed Apr 30 02:54:20 1986 Date-Received: Sat, 3-May-86 17:12:22 EDT References: <4495@cbrma.UUCP> <> Reply-To: g-rh@cca.UUCP (Richard Harter) Organization: Computer Corp. of America, Cambridge Lines: 27 Keywords: Paranoia, malloc Xref: watmath net.lang.c:8788 net.lang.c++:180 Summary: We wrote our own. In article <> faustus@cad.UUCP (Wayne A. Christopher) writes: >In article <4495@cbrma.UUCP>, trl@cbrma.UUCP (Tom Lanning) writes: > >> Are there any "malloc" routines that check for modification of >> malloc's link pointers by the "user's" code? Close to 70% of by bugs >> are stack/memory problems were I use more space than I allocated. > >You could compile the 4.3 malloc() with the -DRCHECK flag, which checks >that you haven't modified the areas beyond your segment when you free it. >Also, if you're REALLY paranoid, write your own malloc that puts lots of >padding around the allocated areas and checks that none of the padding >areas has been changed every time you call malloc() or free(). > We wrote our own, partly out of paranoia an partly out of a probably misguided belief that we could write a more efficient allocator. The main thing that we did was to put all pointers and links in an entirely separate area from the space being allocated. This wins in that pointers never get overwritten -- it loses in that the program does not crash immediately on range errors. We added a one word pad on each end for overwrite testing (can be turned off) and legitimacy tests on all returns of space. We also put in a option to store where requests were coming from. (Hasn't been used in years.) The upshot is that space request/free problems are rare and easily found. However this doesn't avoid the problem of incorrectly dimensioned arrays which are handled by the system and can lead to very peculiar bugs. Richard Harter, SMDS Inc.