[php-src] PR #18858: Add ASAN support to the zend allocator
| From: | danog | Date: | Mon, 16 Jun 2025 12:24:35 +0000 |
| Subject: | [php-src] PR #18858: Add ASAN support to the zend allocator | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-32086@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/18858
Author: danog
This pull request adds ASAN support to the zend allocator, by automatically poisoning all unused
pages, chunks and heap management structures before exiting the alloc, free functions.
Internally, the implementation uses the following rules:
- Always poison memory (re)allocated by private (non-ZEND_API) allocation functions before returning
it
- Unpoison memory (re)allocated by public (ZEND_API) allocation functions before returning **within
the ZEND_API function**
- Always poison freed memory
- Always poison unused memory during reallocation (where new_size < old_size)
- When accessing private heap structures and fields, always unpoison before accessing and repoison
immediately after
- An exception to the above (for simplicity) is the main heap datastructure, which is poisoned
only when entering a ZEND_API function and repoisoned before exiting
This is what allowed me to find https://github.com/php/php-src/issues/18833,
before I found the fast shutdown workaround.