File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16514: Nested generator in zend_test observer
3
+ --INI--
4
+ zend_test.observer.enabled=1
5
+ zend_test.observer.show_init_backtrace=1
6
+ --FILE--
7
+ <?php
8
+
9
+ class Foo {
10
+ public function __destruct () {
11
+ debug_print_backtrace ();
12
+ }
13
+ }
14
+ function bar () {
15
+ yield from foo ();
16
+ }
17
+ function foo () {
18
+ $ foo = new Foo ();
19
+ yield ;
20
+ }
21
+ $ gen = bar ();
22
+ foreach ($ gen as $ dummy );
23
+
24
+ ?>
25
+ --EXPECTF--
26
+ <!-- init '%sgh16514.php' -->
27
+ <!--
28
+ {main} %sgh16514.php
29
+ -->
30
+ <!-- init bar() -->
31
+ <!--
32
+ bar()
33
+ {main} %sgh16514.php
34
+ -->
35
+ <!-- init foo() -->
36
+ <!--
37
+ foo()
38
+ bar()
39
+ {main} %sgh16514.php
40
+ -->
41
+ <!-- init Foo::__destruct() -->
42
+ <!--
43
+ Foo::__destruct()
44
+ bar()
45
+ {main} %sgh16514.php
46
+ -->
47
+ <!-- init debug_print_backtrace() -->
48
+ <!--
49
+ debug_print_backtrace()
50
+ Foo::__destruct()
51
+ bar()
52
+ {main} %sgh16514.php
53
+ -->
54
+ #0 %s(%d): Foo->__destruct()
55
+ #1 %s(%d): bar()
Original file line number Diff line number Diff line change 20
20
#include "zend_observer.h"
21
21
#include "zend_smart_str.h"
22
22
#include "ext/standard/php_var.h"
23
+ #include "zend_generators.h"
23
24
24
25
static zend_observer_fcall_handlers observer_fcall_init (zend_execute_data * execute_data );
25
26
@@ -163,6 +164,11 @@ static void observer_show_init_backtrace(zend_execute_data *execute_data)
163
164
zend_execute_data * ex = execute_data ;
164
165
php_printf ("%*s<!--\n" , 2 * ZT_G (observer_nesting_depth ), "" );
165
166
do {
167
+ if (UNEXPECTED (!ex -> func )) {
168
+ ex = zend_generator_check_placeholder_frame (ex );
169
+ ZEND_ASSERT (ex -> func );
170
+ }
171
+
166
172
zend_function * fbc = ex -> func ;
167
173
int indent = 2 * ZT_G (observer_nesting_depth ) + 4 ;
168
174
if (fbc -> common .function_name ) {
You can’t perform that action at this time.
0 commit comments