mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Rethrow exceptions in fiber destructor
We need to make sure that HANDLE_EXCEPTION is set when the fiber throws during destruction. Fixes oss-fuzz #33875.
This commit is contained in:
parent
c15dc63ad2
commit
fb374f56a7
21
Zend/tests/fibers/throw-during-fiber-destruct.phpt
Normal file
21
Zend/tests/fibers/throw-during-fiber-destruct.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Make sure exceptions are rethrown when throwing from fiber destructor
|
||||
--FILE--
|
||||
<?php
|
||||
$fiber = new Fiber(function() {
|
||||
try {
|
||||
Fiber::suspend();
|
||||
} finally {
|
||||
throw new Exception("Exception 2");
|
||||
}
|
||||
});
|
||||
$fiber->start();
|
||||
unset($fiber);
|
||||
throw new Exception("Exception 1");
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught Exception: Exception 2 in %s:%d
|
||||
Stack trace:
|
||||
#0 [internal function]: {closure}()
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
@ -398,6 +398,11 @@ static void zend_fiber_object_destroy(zend_object *object)
|
||||
zend_fiber_switch_to(fiber);
|
||||
|
||||
if (EG(exception)) {
|
||||
if (!exception && EG(current_execute_data) && EG(current_execute_data)->func
|
||||
&& ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) {
|
||||
zend_rethrow_exception(EG(current_execute_data));
|
||||
}
|
||||
|
||||
zend_exception_set_previous(EG(exception), exception);
|
||||
|
||||
if (EG(flags) & EG_FLAGS_IN_SHUTDOWN) {
|
||||
|
Loading…
Reference in New Issue
Block a user