Mail Archives: djgpp-workers/2004/12/10/22:25:17
Eli Zaretskii wrote:
> > From: CBFalconer <cbfalconer AT yahoo DOT com>
> >
> > How does it compare to the malldbg package that I built to your
> > specifications for nmalloc?
>
> YAMD can catch more bugs, and what's more important, it can catch
> them earlier than any tool like malldbg.
>
> What YAMD does is unmap from the address space memory that surrounds
> the buffer you get from malloc. So if a program accesses that memory,
> e.g., reads or writes beyond the limits of the allocated buffer, it
> immediately gets hit with a GPF exception. YAMD catches that
> exception and logs it with the traceback, so you can easily see what
> code was caught red-handed.
>
> The only limitation of this technique, IIRC, is that you can only
> unmap page-aligned regions of memory. This leaves the portion of
> memory between the end of the allocated buffer and the next page
> unprotected on the hardware level. AFAIK, YAMD uses software
> protection for that part (it fills the unallocated memory with magic
> bytes), but that is less powerful than the hardware-assisted
> protection.
I can see how that is much more immediate at catching overwrites,
etc. You are aware that nmalloc includes a SAVEMEMORY define that
removes guard words at the ends of allocations, which in turn
enables most overwrites to be detected early (at the cost of some
overhead). My original design included the guards, but people were
worried about memory use in smaller systems, and I already had a
larger control area that 2.03 malloc.
In addition, with SAVEMEMORY defeated, there is no longer any need
to forbid a zero size allocation. At present at least ALIGN bytes
are always allocated. This provides space to keep track of free
blocks, unneeded in allocated blocks.
--
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
- Raw text -