1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/Zend/tests/gh20714.phpt
Ilija Tovilo fb1ec9a5a7 Fix uncatchable exception thrown in generator
This procedure may be called during i_free_compiled_variables(), when
EG(current_execute_data) is unfortunately already reset to the parent frame.
EG(opline_before_exception) does not actually belong to this frame. Furthermore,
setting opline to EG(exception_op) early will miss a later
zend_rethrow_exception(), which will also miss installation of the correct
EG(opline_before_exception).

Fixes GH-20714
Closes GH-20716
2025-12-16 17:30:05 +01:00

30 lines
397 B
PHP

--TEST--
GH-20714: Uncatchable exception thrown in generator
--CREDITS--
Grégoire Paris (greg0ire)
--FILE--
<?php
function gen(): Generator {
try {
yield 1;
} finally {}
}
function process(): void {
$g = gen();
foreach ($g as $_) {
throw new Exception('ERROR');
}
}
try {
process();
} catch (Exception $e) {
echo "Caught\n";
}
?>
--EXPECT--
Caught