Summary
A by-reference foreach over a static array property leaks three heap blocks. Output is correct.
Repro
<?php
class C { public static array $x = [1, 2]; }
foreach (C::$x as &$v) { $v = $v * 2; }
unset($v);
echo implode(",", C::$x);
main 2829ce0ab, macOS ARM64, --heap-debug:
2,4
HEAP DEBUG: allocs=7 frees=4 live_blocks=3
PHP 8.4.23 prints the same 2,4. The static property is mutated correctly — this is purely a lifetime issue.
Notes
Found while fixing #642 (by-ref foreach over an instance property, which corrupted the property outright). The static path behaves correctly by comparison — the writes land and nothing is freed early — but it does not balance its allocations.
Measured identically before and after that fix, so it is pre-existing and independent: the static path is untouched by #651.
Summary
A by-reference
foreachover a static array property leaks three heap blocks. Output is correct.Repro
main2829ce0ab, macOS ARM64,--heap-debug:PHP 8.4.23 prints the same
2,4. The static property is mutated correctly — this is purely a lifetime issue.Notes
Found while fixing #642 (by-ref
foreachover an instance property, which corrupted the property outright). The static path behaves correctly by comparison — the writes land and nothing is freed early — but it does not balance its allocations.Measured identically before and after that fix, so it is pre-existing and independent: the static path is untouched by #651.