mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3'
This commit is contained in:
35
Zend/tests/generators/gh14387.phpt
Normal file
35
Zend/tests/generators/gh14387.phpt
Normal file
@@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
GH-14387 (Crash when stack walking in destructor of yielded from values during Generator->throw())
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function prime(Generator $generator) {
|
||||
$generator->valid();
|
||||
}
|
||||
|
||||
$g = (function () {
|
||||
yield from [null, new class {
|
||||
function __destruct() {
|
||||
// Trigger a stack walk, hitting a bad frame.
|
||||
throw new Exception;
|
||||
}
|
||||
}];
|
||||
})();
|
||||
|
||||
prime($g);
|
||||
|
||||
$g->throw(new Error);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught Error in %s:%d
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
|
||||
Next Exception in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): class@anonymous->__destruct()
|
||||
#1 [internal function]: {%s}()
|
||||
#2 %s(%d): Generator->throw(Object(Error))
|
||||
#3 {main}
|
||||
thrown in %s on line %d
|
||||
@@ -466,6 +466,7 @@ static void zend_generator_throw_exception(zend_generator *generator, zval *exce
|
||||
* to pretend the exception happened during the YIELD opcode. */
|
||||
EG(current_execute_data) = generator->execute_data;
|
||||
generator->execute_data->opline--;
|
||||
generator->execute_data->prev_execute_data = original_execute_data;
|
||||
|
||||
if (exception) {
|
||||
zend_throw_exception_object(exception);
|
||||
|
||||
Reference in New Issue
Block a user