[php-src] PR #22530: Fix GH-22516: widen zend_mm srun free counter to cover bin 0
| From: | iliaal | Date: | Tue, 30 Jun 2026 20:46:41 +0000 |
| Subject: | [php-src] PR #22530: Fix GH-22516: widen zend_mm srun free counter to cover bin 0 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36752@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22530
Author: iliaal
zend_mm_gc()'s per-page free-slot counter is stored in a 9-bit field
(ZEND_MM_SRUN_FREE_COUNTER_MASK, max 511), but bin 0 has 512 slots, so a fully-free bin-0 page
drives the counter to 512, overflows the field, and reads back as 0. The fully-free-page checks
(counter == bin_elements) then never fire and the page is never reclaimed. Widening the field to 10
bits (0x03ff0000) fixes it: bit 25 was unused, and the change is a no-op for every other bin since
they all hold at most 256 slots.
Reachable only where ZEND_MM_MIN_USEABLE_BIN_SIZE == 8, i.e. 32-bit or heap-protection-disabled
builds. On 64-bit with heap protection, zend_mm_alloc_heap() rounds every sub-16-byte request up to
bin 1, so bin 0 is never used and the change is inert there.
Fixes #22516