Skip to content

array_shift of a mixed list whose result is only compared with === null leaks the shifted element #314

Closed

Description

@blacktrs

Summary

array_shift of a mixed list whose result is only compared with === null leaks the shifted element.

Repro

<?php
function f(int $n): int
{
    $q = [];
    $t = 0;
    for ($i = 0; $i < $n; $i++) {
        $q[] = str_repeat('x', 64) . $i;
        $q[] = [$i];
        if (array_shift($q) === null) { $t++; }
        array_shift($q);
    }
    return $t;
}
f(1000);
$m0 = memory_get_peak_usage();
f(300000);
echo (memory_get_peak_usage() - $m0) < 4000000 ? "flat" : "LEAK", "\n";

Expected (php)

flat

Actual (manticore 6df3b897, Darwin arm64)

LEAK

Tracking

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