Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Sep 1997 05:55:09 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        perhaps@yes.no (Eivind Eklund)
Cc:        tlambert@primenet.com, nate@mt.sri.com, phk@critter.freebsd.dk, gram@cdsec.com, hackers@FreeBSD.ORG
Subject:   Re: Bug in malloc/free (was: Memory leak in getservbyXXX?)
Message-ID:  <199709220555.WAA15014@usr07.primenet.com>
In-Reply-To: <199709211735.TAA20824@bitbox.follo.net> from "Eivind Eklund" at Sep 21, 97 07:35:04 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709220555.WAA15014>