xref: /php-src/Zend/tests/gh15108-006.phpt (revision 99e0d3fe)
1--TEST--
2GH-15108 006: 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);
32var_dump($a->current());
33var_dump($b->current());
34
35$fiber = new Fiber(function () use ($a, $b, $g) {
36    $a->next();
37    var_dump("not executed");
38});
39
40$ref = $fiber;
41
42$fiber->start();
43
44?>
45==DONE==
46--EXPECT--
47string(3) "foo"
48string(3) "foo"
49==DONE==
50