Malloc debugging (Was: Medit crash)

From: Rasmus Ronlev (raro94ab@STUDENT.ECON.CBS.DK)
Date: 11/28/97


Luis Pedro Passos Carvalho wrote:

> The dynamic memory you allocate is stored in a linked list, as well as your
> freed memory. In the beginning of each malloc'ed block there is an header,
> that indicates the size of the block, and the next block in the list.
> When you free a block, it runs through the list and updates it in order to
> reflect the change.
>
> In order for the implementation of free and malloc to be fast, no error checking
> is done, so it usually considers that the header is imediatey before the place
> you indicate.

Hummmm.... Does anyone have any ideas what I can do considering I am runningthe mud on
Linux as well as developing on a Linux box ? I've tried the electric
fence debugging library, but that doesn't detect any errors, which I was expecting
if there are some routines, who are writing over their allocated address space.

I'm currently in the stage of downloading a source version of libc (5.4.38) and
compile this with debugging information in it. (This also included installing a
bunch of new stuff like gcc etc, etc. *grin*).

Anyway, would it be possible and/or a good idea making some sort of wrapper
for all the 'writes' into memory ? I guess doing that with the code I'm currently
using
would really hog up CPU time *snicker* Not to mention making it take a century to
boot up the mud. But, I'm desperately in need of a good way to find and bugfix such
problems like this (also in the future).

In the case of writing a wrapper, what functions would I need to make a wrapper for,
and where would I find the information on the structures (the header size) for the
malloc() function, so I can also test for occurances, that overwrite those parts of
the
memory... ?


> I hope I made myself understandable, and not a raving lunatic.

Perfectly. In fact this made me realize, that I also need to find a way to detect
ifwrites to the memory are corrupting allocated memory, or their 'confuguration
structures' that malloc uses. Now all that's left is the solution to this problem *g*

So, if anyone has some insight on this, I'd really love to hear from you. If there's
some sort of mailinglist or newsgroup that you know of, that I would benefit of
subscribing to, that'd also be good.

Regards,
Rasmus


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST