mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
![]() Debugging memory corruption issues in production can be difficult when it's not possible to use a debug build or ASAN/MSAN/Valgrind (e.g. for performance reasons). This change makes it possible to enable some basic heap debugging helpers without rebuilding PHP. This is controlled by the environment variable ZEND_MM_DEBUG. The env var takes a comma-separated list of parameters: - poison_free=byte: Override freed blocks with the specified byte value (represented as a number) - poison_alloc=byte: Override newly allocated blocks with the specified byte value (represented as a number) - padding=bytes: Pad allocated blocks with the specified amount of bytes (if non-zero, a value >= 16 is recommended to not break alignments) - check_freelists_on_shutdown=0|1: Enable checking freelist consistency [1] on shutdown Example: ZEND_MM_DEBUG=poison_free=0xbe,poison_alloc=0xeb,padding=16,check_freelists_on_shutdown=1 php ... This is implemented by installing custom handlers when ZEND_MM_DEBUG is set. This has zero overhead when ZEND_MM_DEBUG is not set. When ZEND_MM_DEBUG is set, the overhead is about 8.5% on the Symfony Demo benchmark. Goals: - Crash earlier after a memory corruption, to extract a useful backtrace - Be usable in production with reasonable overhead - Having zero overhead when not enabled Non-goals: - Replace debug builds, valgrind, ASAN, MSAN or other sanitizers [1] https://github.com/php/php-src/pull/14054 Co-authored-by: Tim Düsterhus <timwolla@googlemail.com> |
||
---|---|---|
.. | ||
tests | ||
config.m4 | ||
config.w32 | ||
fiber.c | ||
fiber.h | ||
fiber.stub.php | ||
fiber_arginfo.h | ||
iterators.c | ||
iterators.h | ||
iterators.stub.php | ||
iterators_arginfo.h | ||
object_handlers.c | ||
object_handlers.h | ||
object_handlers.stub.php | ||
object_handlers_arginfo.h | ||
observer.c | ||
observer.h | ||
php_test.h | ||
test.c | ||
test.stub.php | ||
test_arginfo.h | ||
zend_mm_custom_handlers.c | ||
zend_mm_custom_handlers.h |