xref: /PHP-8.2/Zend/tests/gh9916-006.phpt (revision 1173c2e6)
1--TEST--
2Bug GH-9916 006 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3--FILE--
4<?php
5$gen = (function() {
6    $x = new stdClass;
7    yield from (function () {
8        $x = new stdClass;
9        print "Before suspend\n";
10        Fiber::suspend();
11        print "After suspend\n";
12        yield;
13    })();
14    yield from (function () {
15        $x = new stdClass;
16        print "Before exit\n";
17        exit;
18        print "Not executed\n";
19        yield;
20    })();
21    yield;
22})();
23$fiber = new Fiber(function() use ($gen, &$fiber) {
24    $gen->current();
25    print "Fiber return\n";
26});
27$fiber->start();
28$fiber->resume();
29$gen->next();
30$gen->current();
31?>
32==DONE==
33--EXPECT--
34Before suspend
35After suspend
36Fiber return
37Before exit
38