xref: /php-src/Zend/tests/generators/gh14387.phpt (revision be7f3aa4)
1--TEST--
2GH-14387 (Crash when stack walking in destructor of yielded from values during Generator->throw())
3--FILE--
4<?php
5
6function prime(Generator $generator) {
7	$generator->valid();
8}
9
10$g = (function () {
11	yield from [null, new class {
12		function __destruct() {
13			// Trigger a stack walk, hitting a bad frame.
14			throw new Exception;
15		}
16	}];
17})();
18
19prime($g);
20
21$g->throw(new Error);
22
23?>
24--EXPECTF--
25Fatal error: Uncaught Error in %s:%d
26Stack trace:
27#0 {main}
28
29Next Exception in %s:%d
30Stack trace:
31#0 %s(%d): class@anonymous->__destruct()
32#1 [internal function]: {%s}()
33#2 %s(%d): Generator->throw(Object(Error))
34#3 {main}
35  thrown in %s on line %d
36