Skip to content

A non-builtin string function (trim) applied to an int held in a cell leaks the rendered string on every call. #128

Closed

Description

@blacktrs

Summary

A non-builtin string function (trim) applied to an int held in a cell leaks the rendered string on every call.

Repro

<?php
function mv(int $i): mixed { return $i % 2 === 0 ? $i * 1000 : "s$i"; }
$m0 = memory_get_peak_usage();
$t = 0;
for ($i = 0; $i < 300000; $i++) { $t += strlen(trim(mv($i * 2 + 2))); }
$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 32f98675, Darwin arm64)

LEAK
(stderr: grew 18 MB)

Tracking

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