Skip to content

A hooked property read kept in a typed local or used as the left side of ?? leaks the fresh string the get hook built. #491

Open

Description

@blacktrs

Summary

A hooked property read kept in a typed local or used as the left side of ?? leaks the fresh string the get hook built.

Repro

<?php
class A { public string $s { get => str_repeat('x', 40) . 'y'; } }
$a = new A();
$m0 = memory_get_peak_usage();
for ($i = 0; $i < 500000; $i++) {
    $z = $a->s;
    $w = $a->s ?? '';
}
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $mb < 4 ? "flat\n" : "LEAK\n";

Expected (php)

flat

Actual (manticore 93459368, Darwin arm64)

LEAK
(stderr: grew 122 MB)

Tracking

Known-bug repro: tests/aot/repro/leak/hook_read_kept_in_local.php — bash tests/aot/xfail.sh -k hook_read_kept_in_local 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 26, 2026
  2. blacktrs commented on Oct 26, 2026

    @blacktrs
    ContributorAuthor

    Related: #460 (get hook fresh-value leak, closed) fixed the temp-use path; this is the remaining path where the read is kept in a typed local or used with ??.

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