1--TEST--
2Observer: Function observing in fibers with bailout in fiber
3--EXTENSIONS--
4zend_test
5--INI--
6zend_test.observer.enabled=1
7zend_test.observer.show_output=1
8zend_test.observer.observe_all=1
9zend_test.observer.fiber_init=1
10zend_test.observer.fiber_switch=1
11zend_test.observer.fiber_destroy=1
12memory_limit=100M
13--SKIPIF--
14<?php
15if (getenv("USE_ZEND_ALLOC") === "0") die("skip requires ZendMM because it uses the memory limit");
16?>
17--FILE--
18<?php
19
20$notBailedOutFiber = new Fiber(function (): void {
21    var_dump(1);
22    Fiber::suspend();
23});
24
25$notBailedOutFiber->start();
26
27$fiber = new Fiber(function (): void {
28    var_dump(2);
29    Fiber::suspend();
30    str_repeat('A', 200_000_000);
31});
32
33$fiber->start();
34$fiber->resume();
35
36?>
37--EXPECTF--
38<!-- init '%s' -->
39<file '%s'>
40  <!-- init Fiber::__construct() -->
41  <Fiber::__construct>
42  </Fiber::__construct>
43  <!-- init Fiber::start() -->
44  <Fiber::start>
45<!-- alloc: %s -->
46<!-- switching from fiber %s to %s -->
47<init '%s'>
48    <!-- init {closure:%s:%d}() -->
49    <{closure:%s:%d}>
50      <!-- init var_dump() -->
51      <var_dump>
52int(1)
53      </var_dump>
54      <!-- init Fiber::suspend() -->
55      <Fiber::suspend>
56<!-- switching from fiber %s to %s -->
57<suspend '%s'>
58      </Fiber::start>
59      <Fiber::__construct>
60      </Fiber::__construct>
61      <Fiber::start>
62<!-- alloc: %s -->
63<!-- switching from fiber %s to %s -->
64<init '%s'>
65        <!-- init {closure:%s:%d}() -->
66        <{closure:%s:%d}>
67          <var_dump>
68int(2)
69          </var_dump>
70          <Fiber::suspend>
71<!-- switching from fiber %s to %s -->
72<suspend '%s'>
73          </Fiber::start>
74          <!-- init Fiber::resume() -->
75          <Fiber::resume>
76<!-- switching from fiber %s to %s -->
77<resume '%s'>
78          </Fiber::suspend>
79          <!-- init str_repeat() -->
80          <str_repeat>
81
82Fatal error: Allowed memory size of 104857600 bytes exhausted %s on line %d
83          </str_repeat>
84        </{closure:%s:%d}>
85<!-- switching from fiber %s to %s -->
86<returned '%s'>
87<!-- destroy: %s -->
88      </Fiber::resume>
89    </file '%s'>
90