backtrace-deep-nesting.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Backtrace in deeply nested function call
  3. --FILE--
  4. <?php
  5. function suspend_fiber(int $level): void
  6. {
  7. if ($level >= 10) {
  8. $value = \Fiber::suspend($level);
  9. failing_function($value);
  10. }
  11. suspend_fiber($level + 1);
  12. }
  13. function failing_function(string $value): never
  14. {
  15. throw_exception();
  16. }
  17. function throw_exception(): never
  18. {
  19. throw new Exception;
  20. }
  21. $fiber = new Fiber(function (): void {
  22. suspend_fiber(0);
  23. });
  24. $fiber->start();
  25. $fiber->resume('test');
  26. ?>
  27. --EXPECTF--
  28. Fatal error: Uncaught Exception in %sbacktrace-deep-nesting.php:%d
  29. Stack trace:
  30. #0 %sbacktrace-deep-nesting.php(%d): throw_exception()
  31. #1 %sbacktrace-deep-nesting.php(%d): failing_function('test')
  32. #2 %sbacktrace-deep-nesting.php(%d): suspend_fiber(10)
  33. #3 %sbacktrace-deep-nesting.php(%d): suspend_fiber(9)
  34. #4 %sbacktrace-deep-nesting.php(%d): suspend_fiber(8)
  35. #5 %sbacktrace-deep-nesting.php(%d): suspend_fiber(7)
  36. #6 %sbacktrace-deep-nesting.php(%d): suspend_fiber(6)
  37. #7 %sbacktrace-deep-nesting.php(%d): suspend_fiber(5)
  38. #8 %sbacktrace-deep-nesting.php(%d): suspend_fiber(4)
  39. #9 %sbacktrace-deep-nesting.php(%d): suspend_fiber(3)
  40. #10 %sbacktrace-deep-nesting.php(%d): suspend_fiber(2)
  41. #11 %sbacktrace-deep-nesting.php(%d): suspend_fiber(1)
  42. #12 %sbacktrace-deep-nesting.php(%d): suspend_fiber(0)
  43. #13 [internal function]: {closure}()
  44. #14 %sbacktrace-deep-nesting.php(%d): Fiber->resume('test')
  45. #15 {main}
  46. thrown in %sbacktrace-deep-nesting.php on line %d