Skip to content

Reading a by-ref out parameter (union array|object|null) that a generator method assigns lazily segfaults in the caller #177

Closed

Description

@blacktrs

Summary

Reading a by-ref out parameter (union array|object|null) that a generator method assigns lazily segfaults in the caller.

Repro

<?php
final class Res implements IteratorAggregate
{
    public function __construct(private string $prefix) {}
    public function getPrefix(): string { return $this->prefix; }
    public function getIterator(): Generator { yield '/a.php' => 1; yield '/b.php' => 2; }
}

final class Loader
{
    protected function glob(string $pattern, array|Res|null &$resource = null, bool $ignoreErrors = false): iterable
    {
        if ($pattern === 'missing') {
            $resource = [];
            return;
        }
        $resource = new Res($pattern);
        yield from $resource;
    }

    /** @return string[] */
    public function find(string $pattern): array
    {
        $out = [];
        foreach ($this->glob($pattern, $resource) as $path => $info) {
            $out[] = $resource->getPrefix() . $path;
        }
        return $out;
    }
}

echo implode(',', (new Loader())->find('src')), "\n";

Expected (php)

src/a.php,src/b.php

Actual (manticore 27a37db4, Darwin arm64)


[exit code 139 — SIGSEGV]

Tracking

Known-bug repro: tests/aot/repro/crash/generator_byref_out_param_union_null.php — bash tests/aot/xfail.sh -k generator_byref_out_param_union_null 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 11, 2026
  2. added 2 commits that reference this issue on Oct 14, 2026
    bbcdc39
    7f2be54
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