xref: /php-src/Zend/tests/gh15275-006.phpt (revision c767fec2)
1--TEST--
2GH-15275 006: Crash during GC of suspended generator delegate
3--FILE--
4<?php
5
6class It implements \IteratorAggregate
7{
8    public function getIterator(): \Generator
9    {
10        yield 'foo';
11        echo "baz\n";
12        throw new \Exception();
13    }
14
15    public function __destruct()
16    {
17        throw new \Exception();
18    }
19}
20
21function f() {
22    var_dump(new stdClass, yield from new It());
23}
24
25$gen = f();
26
27var_dump($gen->current());
28$gen->next();
29
30gc_collect_cycles();
31
32?>
33==DONE==
34--EXPECTF--
35string(3) "foo"
36baz
37
38Fatal error: Uncaught Exception in %s:9
39Stack trace:
40#0 %s(19): It->getIterator()
41#1 [internal function]: f()
42#2 %s(25): Generator->next()
43#3 {main}
44
45Next Exception in %s:14
46Stack trace:
47#0 %s(19): It->__destruct()
48#1 [internal function]: f()
49#2 %s(25): Generator->next()
50#3 {main}
51  thrown in %s on line 14
52