xref: /PHP-8.2/Zend/tests/gh15108-004.phpt (revision 99e0d3fe)
1--TEST--
2GH-15108 004: Segfault with delegated generator in suspended fiber
3--FILE--
4<?php
5
6function gen1() {
7    yield 'foo';
8    Fiber::suspend();
9    var_dump("not executed");
10};
11
12function gen2($gen) {
13    yield from $gen;
14    var_dump("not executed");
15}
16
17$a = gen1();
18/* Both $b and $c have a root marked with IN_FIBER, but only $b is actually
19 * running in a fiber (at shutdown) */
20$b = gen2($a);
21$c = gen2($a);
22
23$fiber = new Fiber(function () use ($a, $b, $c) {
24    var_dump($b->current());
25    var_dump($c->current());
26    $b->next();
27    var_dump("not executed");
28});
29
30$ref = $fiber;
31
32$fiber->start();
33
34?>
35==DONE==
36--EXPECT--
37string(3) "foo"
38string(3) "foo"
39==DONE==
40