1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Check current_execute_data instead of flags in fiber destructor

Checking EG(current_exectue_data) throws into the previous fiber instead of triggering a fatal error during shutdown. A fatal error is triggered only if the throwing destroyed fiber was resumed from {main}.
This commit is contained in:
Aaron Piotrowski
2021-05-05 10:44:55 -05:00
parent f9ac667b98
commit 779fe8e43a
2 changed files with 48 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
--TEST--
Throw in multiple destroyed fibers after shutdown
--FILE--
<?php
$fiber = new Fiber(function (): void {
$fiber1 = new Fiber(function (): void {
try {
Fiber::suspend();
} finally {
throw new Exception('test1');
}
});
$fiber1->start();
$fiber2 = new Fiber(function (): void {
try {
Fiber::suspend();
} finally {
throw new Exception('test2');
}
});
$fiber2->start();
Fiber::suspend();
});
$fiber->start();
echo "done\n";
?>
--EXPECTF--
done
Fatal error: Uncaught Exception: test1 in %sthrow-in-multiple-destroyed-fibers-after-shutdown.php:%d
Stack trace:
#0 [internal function]: {closure}()
#1 {main}
Next Exception: test2 in %sthrow-in-multiple-destroyed-fibers-after-shutdown.php:%d
Stack trace:
#0 [internal function]: {closure}()
#1 {main}
thrown in %sthrow-in-multiple-destroyed-fibers-after-shutdown.php on line %d

View File

@@ -405,7 +405,7 @@ static void zend_fiber_object_destroy(zend_object *object)
zend_exception_set_previous(EG(exception), exception);
if (EG(flags) & EG_FLAGS_IN_SHUTDOWN) {
if (!EG(current_execute_data)) {
zend_exception_error(EG(exception), E_ERROR);
}
} else {