Skip to content

An array union (+ / +=) stored into an array element never releases the fresh result buffer. #193

Closed

Description

@blacktrs

Summary

An array union (+ / +=) stored into an array element never releases the fresh result buffer.

Repro

<?php
function churn(int $n): int
{
    $keep = [['a' => 1, 'b' => 2]];
    $p = ['c' => 3, 'd' => 4];
    $len = 0;
    for ($i = 0; $i < $n; $i++) { $k = $keep; $k[0] += $p; $len += count($k[0]); }
    return $len;
}
churn(2000);
$before = memory_get_peak_usage();
churn(200000);
echo memory_get_peak_usage() - $before < 2 << 20 ? "flat\n" : "grows\n";

Expected (php)

flat

Actual (manticore 2fe0c506, Darwin arm64)

grows

Tracking

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

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