no-switch-gc.phpt 824 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. Context switches are prevented during GC collect cycles
  3. --FILE--
  4. <?php
  5. $fiber = new Fiber(function () {
  6. call_user_func(function () {
  7. $a = new class () {};
  8. $b = new class () {
  9. public function __destruct() {
  10. Fiber::suspend();
  11. }
  12. };
  13. $a->next = $b;
  14. $b->next = $a;
  15. });
  16. gc_collect_cycles();
  17. });
  18. $fiber->start();
  19. ?>
  20. --EXPECTF--
  21. Fatal error: Uncaught FiberError: Cannot switch fibers in current execution context in %sno-switch-gc.php:%d
  22. Stack trace:
  23. #0 %sno-switch-gc.php(%d): Fiber::suspend()
  24. #1 [internal function]: class@anonymous->__destruct()
  25. #2 %sno-switch-gc.php(%d): gc_collect_cycles()
  26. #3 [internal function]: {closure}()
  27. #4 %sno-switch-gc.php(%d): Fiber->start()
  28. #5 {main}
  29. thrown in %sno-switch-gc.php on line %d