Re: Memory trashing

From: Date: Sat, 16 Jan 1999 03:53:39 +0000
Subject: Re: Memory trashing
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-3584@lists.php.net to get a copy of this message
On 15 Jan 1999, Manuel Lemos wrote: > Hello, > > For a long time I have been detecting memory trashing in PHP. Because I > running PHP on a platform that is not quite Unix-like but has a library > that offers some POSIX compatibility, I haven't talked about this before, > as the memory trashing could be cause by some bug in the library. But now > I suspect that might not be quite the case. > > While looking at memory allocation code, I noticed that it doesn't seem to > have memory boundaries trashing detection, ie, code that detects if memory > was used outside of the boundaries of the allocated space. > > This works by having the allocation functions to allocate some extra space. > The extra spaced would be filled with some odd bytes forming memory walls. > Usually, there should be two memory walls, one before and another after, > the space that is returned to the code that calls the allocation function. > > When the allocated block is freed, the memory walls are verified. If they > remain intact (the odd bytes are still there unchanged) everything is ok > and the memory if freed. Otherwise, PHP should dump some debugging > information pointing to the source and the line of the code that allocated > and is freeing the original block. Of course, this would only be enabled > when PHP is compiled in debugging mode. > > I believe having this code built in PHP allocation functions could help > tracking a lot of subtle bugs that may lead to spurious execution faults > and may lead to the dreaded "Document contains no data" messages. > > What do you think of the idea? Need any help to implement it? Surpringly enough, we've already implemented this in the zend version of the memory manager. There's nothing specific to zend in it so I guess it can be ported back to PHP3, but I'm not sure we want to do that. Zeev -- ----------------------------------------------------- Zeev Suraski <zeev@zend.com> For a PGP public key, finger bourbon@netvision.net.il -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3584) next »