Skip to content

Two function locals stored by reference in an array property outlive their function: reads and writes through them corrupt the heap. #341

Closed

Description

@blacktrs

Summary

Two function locals stored by reference in an array property outlive their function: reads and writes through them corrupt the heap.

Repro

<?php
class H {
    /** @var array<int,mixed> */
    public array $refs = [];
    function bind(int $k, mixed &$v): void { $this->refs[$k] = &$v; }
}
class O { public string $n = "obj"; }
function mk(): H { $h = new H; $h->bind(1, $a); $h->bind(2, $b); return $h; }
$o = new O;
$h = mk();
$h->refs[1] = "v1";
$h->refs[2] = "v2";
$o2 = new O;
echo $o->n, "\n";
echo $h->refs[1], $h->refs[2], "\n";

Expected (php)

obj
v1v2

Actual (manticore c70c8bef, Darwin arm64)

obj
2.1285742276093E-3143.042758046102E-314

Tracking

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

    bugcrash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions