Path: utzoo!attcan!uunet!ginosko!gem.mps.ohio-state.edu!uwm.edu!mailrus!iuvax!watmath!watcgl!jyegiguere
From: jyegiguere@watcgl.waterloo.edu (Eric Giguere)
Newsgroups: comp.sys.amiga
Subject: Re: task exceptions
Message-ID: <11665@watcgl.waterloo.edu>
Date: 27 Sep 89 21:52:58 GMT
References: <24642@louie.udel.EDU> 
Reply-To: jyegiguere@watcgl.waterloo.edu (Eric Giguere)
Organization: U. of Waterloo, Ontario
Lines: 21

In article  andrewt@watsnew.waterloo.edu (Andrew Thomas) writes:
>My question here is, why the hell doesn't the malloc/free pair have
>some kind of bit or magic number which it sets in the header block
>which says whether that segment of memory is allocated or freed, so
>the check can be done by free and the problem goes away forever.  The
>only overhead is (perhaps as much as) 1 byte per memory segment, a
>compare and write in free, and a write in malloc.  I'm willing to pay
>the three instructions for the safety it offers.
                        ^^^^^^^^^^^^^^^^^^^^^^^^

Unfortunately it doesn't offer much safety.  Remember that on the Amiga
all tasks share the same memory space... if a pointer from task 1 decides
to point off to never-never land it might stomp all over task 2's memory
space... and then tinker bell comes to pay a visit.

The point is, there is no way to prevent someone from altering memory
that you alloc.... if someone accidentally changes the control byte
(it probably would take more than one byte, remember memory is aligned
along 4-byte boundaries) then it's bye-bye time.

Eric