xref: /PHP-8.3/Zend/tests/gh15108-007.phpt (revision 99e0d3fe)
1--TEST--
2GH-15108 007: Segfault with delegated generator in suspended fiber
3--FILE--
4<?php
5
6class It implements \IteratorAggregate
7{
8    public function getIterator(): \Generator
9    {
10        yield 'foo';
11        Fiber::suspend();
12        var_dump("not executed");
13    }
14}
15
16function f() {
17    yield from new It();
18}
19
20function g() {
21    yield from f();
22}
23
24function gen($gen) {
25    /* $gen is an intermediate node and will not be marked with IN_FIBER */
26    yield from $gen;
27}
28
29$g = g();
30$a = gen($g);
31$b = gen($g);
32$c = gen($g);
33$d = gen($g);
34var_dump($a->current());
35var_dump($b->current());
36
37$fiber = new Fiber(function () use ($a, $b, $c, $d, $g) {
38    $b->next();
39    var_dump("not executed");
40});
41
42$ref = $fiber;
43
44$fiber->start();
45
46?>
47==DONE==
48--EXPECT--
49string(3) "foo"
50string(3) "foo"
51==DONE==
52