Skip to content

A store into a by-reference closure capture leaks a string per store. #348

Closed

Description

@blacktrs

Summary

A store into a by-reference closure capture leaks a string per store.

Repro

<?php
function app(string &$t, string $x): void { $f = function () use (&$t, $x) { $t = str_repeat($x, 30); }; $f(); }
function loopit(): void { $s = "s"; for ($i = 0; $i < 1000; $i++) { app($s, "x"); } }
loopit();
$b = memory_get_peak_usage();
for ($j = 0; $j < 200; $j++) { loopit(); }
echo memory_get_peak_usage() - $b < 1024 * 1024 ? "flat\n" : "grew\n";

Expected (php)

flat

Actual (manticore ecbec1c2, Darwin arm64)

grew

Tracking

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