php-src/Zend/tests/fibers/no-switch-gc.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

36 lines
824 B
PHP

--TEST--
Context switches are prevented during GC collect cycles
--FILE--
<?php
$fiber = new Fiber(function () {
call_user_func(function () {
$a = new class () {};
$b = new class () {
public function __destruct() {
Fiber::suspend();
}
};
$a->next = $b;
$b->next = $a;
});
gc_collect_cycles();
});
$fiber->start();
?>
--EXPECTF--
Fatal error: Uncaught FiberError: Cannot switch fibers in current execution context in %sno-switch-gc.php:%d
Stack trace:
#0 %sno-switch-gc.php(%d): Fiber::suspend()
#1 [internal function]: class@anonymous->__destruct()
#2 %sno-switch-gc.php(%d): gc_collect_cycles()
#3 [internal function]: {closure}()
#4 %sno-switch-gc.php(%d): Fiber->start()
#5 {main}
thrown in %sno-switch-gc.php on line %d