Memory trashing
| From: | Manuel Lemos | Date: | Fri, 15 Jan 1999 18:50:38 +0000 |
| Subject: | Memory trashing | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3579@lists.php.net to get a copy of this message | ||
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?
Regards,
Manuel Lemos
E-mail: mlemos@acm.org
URL: http://www.e-na.net/the_author.html
PGP key: finger://mlemos@zeus.ci.ua.pt
--
--
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