xref: /PHP-8.1/Zend/tests/gh9916-008.phpt (revision 1173c2e6)
1--TEST--
2Bug GH-9916 008 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3--FILE--
4<?php
5$it = new class implements Iterator
6{
7    public function current(): mixed
8    {
9        return null;
10    }
11
12    public function key(): mixed
13    {
14        return 0;
15    }
16
17    public function next(): void
18    {
19    }
20
21    public function rewind(): void
22    {
23        $x = new stdClass;
24        print "Before suspend\n";
25        Fiber::suspend();
26    }
27
28    public function valid(): bool
29    {
30        return true;
31    }
32};
33
34$gen = (function() use ($it) {
35    $x = new stdClass;
36    yield from $it;
37})();
38$fiber = new Fiber(function() use ($gen, &$fiber) {
39    $gen->current();
40    print "Not executed";
41});
42$fiber->start();
43?>
44==DONE==
45--EXPECT--
46Before suspend
47==DONE==
48