Skip to content

A try inside a generator restores the backtrace depth saved at try entry. The generator is #90

Closed

Description

@blacktrs

Summary

A try inside a generator restores the backtrace depth saved at try entry. The generator is.

Repro

<?php
// started at the top level and its catch runs when resumed from a deep call: the depth drops to the
// stale value, the callers' pops then take it negative and count(getTrace()) is garbage
// (a large negative on main); a later push writes before the ring. php: 0.
function g() {
    try {
        yield 1;
        throw new Exception('x');
    } catch (Exception $e) {
        yield 2;
    }
}
function deep(int $n, Generator $gen) {
    if ($n > 0) { deep($n - 1, $gen); return; }
    $gen->next();
}
$gen = g();
$gen->current();
deep(50, $gen);
echo count((new Exception('t'))->getTrace()), "\n";

Expected (php)

0

Actual (manticore 3dc6ed40, Darwin arm64)


[exit code 138 — SIGBUS]

Tracking

Known-bug repro: tests/aot/repro/crash/generator_try_restores_stale_backtrace_depth.php — bash tests/aot/xfail.sh -k generator_try_restores_stale_backtrace_depth 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 5, 2026
  2. added a commit that references this issue on Oct 13, 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