Skip to content

A temporary argument (array literal, closure literal) of a call that throws is never released. #145

Closed

Description

@blacktrs

Summary

A temporary argument (array literal, closure literal) of a call that throws is never released.

Repro

<?php
function t(array $a): bool { throw new RuntimeException('x'); }
function run(int $i): int
{
    try { t(['a' . $i, str_repeat('b', 200)]); } catch (RuntimeException $e) { return 1; }
    return 0;
}
for ($i = 0; $i < 200; $i++) { run($i); }
$m0 = memory_get_peak_usage();
for ($i = 0; $i < 20000; $i++) { run($i); }
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $mb < 2 ? "flat\n" : "LEAK\n";

Expected (php)

flat

Actual (manticore 1637d3e6, Darwin arm64)

LEAK
(stderr: grew 6 MB)

Tracking

Known-bug repro: tests/aot/repro/leak/throw_from_call_leaks_temporary_argument.php — bash tests/aot/xfail.sh -k throw_from_call_leaks_temporary_argument 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

  1. added
    bug
    leak
    on Oct 8, 2026
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