From owner-freebsd-hackers Sun Sep 21 22:59:34 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id WAA16091 for hackers-outgoing; Sun, 21 Sep 1997 22:59:34 -0700 (PDT) Received: from usr07.primenet.com (tlambert@usr07.primenet.com [206.165.6.207]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id WAA16084 for ; Sun, 21 Sep 1997 22:59:29 -0700 (PDT) Received: (from tlambert@localhost) by usr07.primenet.com (8.8.5/8.8.5) id WAA15014; Sun, 21 Sep 1997 22:55:10 -0700 (MST) From: Terry Lambert Message-Id: <199709220555.WAA15014@usr07.primenet.com> Subject: Re: Bug in malloc/free (was: Memory leak in getservbyXXX?) To: perhaps@yes.no (Eivind Eklund) Date: Mon, 22 Sep 1997 05:55:09 +0000 (GMT) Cc: tlambert@primenet.com, nate@mt.sri.com, phk@critter.freebsd.dk, gram@cdsec.com, hackers@FreeBSD.ORG In-Reply-To: <199709211735.TAA20824@bitbox.follo.net> from "Eivind Eklund" at Sep 21, 97 07:35:04 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > You could determine that a list is circular by maintaining a count of > > the number of objects that are supposed to be on the freelist. Then > > you count the number of "next" traversals which occur, and when it > > excceeds the count of how many are supposed to be there, then you > > know you have a problem. > > Why make it this hard, and subject to trashing of the list count? The > following code will check for a circular loop (no knowledge of length > required) for a single-linked list: Because we want to locate the erroneous entries, and the entries most likely to have been trashed to create the loop in the first place, in order to report them (and hopefully get the probem corrected). This whole thread has really been about finding problems in code using the memory allocation code. Simply aborting is not useful, either. It assumes that the debugger has knowledge of the malloc library list structure. This structure is internal (ie: never exported, and thus unavailable to the debugger for this use). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.