xref: /PHP-8.3/ext/opcache/tests/gh13817.phpt (revision a18df90a)
1--TEST--
2GH-13712 (Segmentation fault for enabled observers after pass 4)
3--EXTENSIONS--
4opcache
5zend_test
6--INI--
7zend_test.observer.enabled=1
8zend_test.observer.show_output=1
9zend_test.observer.observe_all=1
10opcache.enable=1
11opcache.enable_cli=1
12opcache.optimization_level=0x4069
13--FILE--
14<?php
15
16function inner() {
17	echo "Ok\n";
18}
19
20function foo() {
21	// If stack size is wrong, inner() will corrupt the previous observed frame
22	inner();
23}
24
25// After foo() def so that we land here, with step_two undone for foo() first
26function outer() {
27	// Pass 15 does constant string propagation, which gives a ZEND_INIT_DYNAMIC_FCALL on a const which Pass 4 will optimize
28	// Pass 4 must calc the right stack size here
29	(NAME)();
30}
31
32const NAME = "foo";
33
34outer();
35
36?>
37--EXPECTF--
38<!-- init '%s' -->
39<file '%s'>
40  <!-- init outer() -->
41  <outer>
42    <!-- init foo() -->
43    <foo>
44      <!-- init inner() -->
45      <inner>
46Ok
47      </inner>
48    </foo>
49  </outer>
50</file '%s'>
51
52