You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A get hook returning a freshly built string leaks it when read through a typed, union or erased receiver. #460
A get hook returning a freshly built string leaks it when read through a typed, union or erased receiver.
Repro
<?php
final class A { public int $n = 1; public string $s { get => str_repeat('x', 16384) . $this->n; } }
final class C { public string $s = 'c'; }
function make(): A|false { return new A(); }
function viaMixed(mixed $o): int { return strlen($o->s); }
$a = new A();
$u = make();
$m0 = memory_get_peak_usage();
$t = 0;
for ($i = 0; $i < 2000; $i++) {
$t += strlen($a->s) + strlen($u->s) + viaMixed($i % 2 ? $a : new C());
}
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $t > 0 && $mb < 8 ? "flat\n" : "LEAK\n";
Expected (php)
flat
Actual (manticore dc3883d9, Darwin arm64)
LEAK
(stderr: grew 104 MB)
Tracking
Known-bug repro: tests/aot/repro/leak/hook_get_fresh_value.php — bash tests/aot/xfail.sh -k hook_get_fresh_value reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.
Activity