Skip to content

A local array assigned a string[] on one path and a cell-element array on another is read back as raw strings after an element store (SIGSEGV). #376

Closed

Description

@blacktrs

Summary

A local array assigned a string[] on one path and a cell-element array on another is read back as raw strings after an element store (SIGSEGV).

Repro

<?php
/** @return string[] */
function pieces(string $g): array
{
    return explode(' ', $g);
}

function split(array $p, int $off): array
{
    foreach ($p as $k => $x) {
        if ($off === $k) {
            \array_splice($p, $k, 1, [$x . '1', $x . '2']);
            return $p;
        }
    }
    return $p;
}

function fix(string $g, int $cut): string
{
    $p = pieces($g);
    if ($cut >= 0) {
        $p = split($p, $cut);
    }
    $m = \count($p);
    for ($k = 0; $k < $m; $k++) {
        $c = $p[$k];
        if ($c === 'b') {
            continue;
        }
        if ($c[0] === '#') {
            $p[$k] = '//' . \substr($c, 1);
            continue;
        }
        $p[$k] = '<' . $c . '>';
    }
    return \implode('|', $p);
}

echo fix('a b #c', -1), "\n";
echo fix('a b #c', 1), "\n";

Expected (php)

<a>|b|//c
<a>|<b1>|<b2>|//c

Actual (manticore cc423903, Darwin arm64)


[exit code 139 — SIGSEGV]

Tracking

Known-bug repro: tests/aot/repro/crash/array_local_whole_stores_disagree_on_elem_repr.php — bash tests/aot/xfail.sh -k array_local_whole_stores_disagree_on_elem_repr 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 20, 2026
  2. blacktrs commented on Oct 20, 2026

    @blacktrs
    ContributorAuthor

    Root cause: $p = pieces() (vec[string]) and, on a branch, $p = splitPieces($p) (vec[cell]) merge to vec[unknown]; the next $p[$k] = 's' re-narrows the local to vec[string] (InferNodes::inferStoreElement refines from an unknown element), so the cell buffer is read as raw string pointers.

    A whole-store scan that gives such a local a cell element (forward-cellify at each store) fixes it, but here the conflict only appears AFTER Monomorphize (splitPieces' return becomes vec[cell] post-Mono), and retyping a local then hands vec[cell] to callees already bound to $mono$p0_vec_int-style clones (tests/aot/cases/array_bulk_list_ops regressed that way). Commit 463f1c1c (branch fix/open-bugs-batch2) applies the scan before Monomorphize only. Closing this needs post-Mono call sites to be re-bound (or converted at the argument) when inference moves an argument's element repr — the same hazard behind #369.

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