Skip to content

Leak: a by-ref callee overwriting the caller's owned local never releases the old value #20

Closed

Description

@blacktrs

Summary

Leak: a by-ref callee overwriting the caller's owned local never releases the old value.

Repro

<?php
final class Big { public string $pool; public function __construct() { $this->pool = str_repeat('x', 4096); } }
function set(?Big &$o): void { $o = new Big(); }
function sets(string &$s, int $i): void { $s = str_repeat('s', 4096) . $i; }
$m0 = memory_get_peak_usage();
$x = new Big();
$y = '';
for ($i = 0; $i < 10000; $i++) { set($x); sets($y, $i); }
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $mb < 8 ? "flat\n" : "LEAK\n";

The repro measures its own peak RSS (memory_get_peak_usage()) around the loop and prints flat when it grew by less than 8 MB.

Expected (php 8.5)

flat

Actual (manticore 10affa68, macOS arm64)

LEAK
(stderr: grew 50 MB)

Tracking

Known-bug repro: tests/aot/repro/leak/byref_callee_overwrite.php — bash tests/aot/xfail.sh -k byref_callee_overwrite reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugleak

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions