xref: /PHP-8.4/Zend/tests/gh15275-004.phpt (revision c767fec2)
1--TEST--
2GH-15275 004: 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        gc_collect_cycles();
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  thrown in %s on line 9
45