Skip to content

A closure that captures the previous closure and calls a dynamic method on its result segfaults from the second link on. #167

Closed

Description

@blacktrs

Summary

A closure that captures the previous closure and calls a dynamic method on its result segfaults from the second link on.

Repro

<?php
class Proto {
    public array $log = [];
    public function setK0(mixed $v): static { $this->log[] = 'k0=' . (string)$v; return $this; }
    public function setK1(mixed $v): static { $this->log[] = 'k1=' . (string)$v; return $this; }
}
function build(mixed $prototype, array $keys): mixed {
    $g = static fn () => clone $prototype;
    foreach ($keys as $key) {
        $g = static fn () => $g()->{'set' . $key}(7);
    }
    return $g();
}
echo implode(',', build(new Proto(), ['K0', 'K1'])->log), "\n";

Expected (php)

k0=7,k1=7

Actual (manticore a8517868, Darwin arm64)


[exit code 139 — SIGSEGV]

Tracking

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

    bugcrash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions