php-src/Zend/tests/fibers/no-switch-force-close-finally.phpt
Aaron Piotrowski fdc22744a8
Add API to prevent Fiber switch in select contexts
Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2021-06-14 14:19:00 -05:00

32 lines
673 B
PHP

--TEST--
Cannot start a new fiber in a finally block in a force-closed fiber
--FILE--
<?php
$fiber = new Fiber(function() {
try {
Fiber::suspend();
} finally {
echo "finally\n";
$fiber = new Fiber(function() {
echo "not executed\n";
});
$fiber->start();
}
});
$fiber->start();
?>
--EXPECTF--
finally
Fatal error: Uncaught FiberError: Cannot switch fibers in current execution context in %sno-switch-force-close-finally.php:%d
Stack trace:
#0 %sno-switch-force-close-finally.php(%d): Fiber->start()
#1 [internal function]: {closure}()
#2 {main}
thrown in %sno-switch-force-close-finally.php on line %d