Skip to content

A method call on a temporary of a union return type (S|false) never releases the temporary. #299

Closed

Description

@blacktrs

Summary

A method call on a temporary of a union return type (S|false) never releases the temporary.

Repro

<?php
class S { public string $pad; function __construct(public Db $db) { $this->pad = str_repeat('x', 4096); } function col(): int { return 1; } }
class Db { function q(): S|false { return new S($this); } }
function run(Db $d): int { return $d->q()->col(); }
$d = new Db;
for ($i = 0; $i < 2000; $i++) { run($d); }
$base = memory_get_peak_usage();
for ($i = 0; $i < 60000; $i++) { run($d); }
echo memory_get_peak_usage() - $base < 4 * 1024 * 1024 ? "flat\n" : "grew\n";

Expected (php)

flat

Actual (manticore 3c2723c3, Darwin arm64)

grew

Tracking

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