mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix handling of nested generator in zend_test observer
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "zend_observer.h"
|
||||
#include "zend_smart_str.h"
|
||||
#include "ext/standard/php_var.h"
|
||||
#include "zend_generators.h"
|
||||
|
||||
static zend_observer_fcall_handlers observer_fcall_init(zend_execute_data *execute_data);
|
||||
|
||||
@@ -163,6 +164,11 @@ static void observer_show_init_backtrace(zend_execute_data *execute_data)
|
||||
zend_execute_data *ex = execute_data;
|
||||
php_printf("%*s<!--\n", 2 * ZT_G(observer_nesting_depth), "");
|
||||
do {
|
||||
if (UNEXPECTED(!ex->func)) {
|
||||
ex = zend_generator_check_placeholder_frame(ex);
|
||||
ZEND_ASSERT(ex->func);
|
||||
}
|
||||
|
||||
zend_function *fbc = ex->func;
|
||||
int indent = 2 * ZT_G(observer_nesting_depth) + 4;
|
||||
if (fbc->common.function_name) {
|
||||
|
||||
57
ext/zend_test/tests/gh16514.phpt
Normal file
57
ext/zend_test/tests/gh16514.phpt
Normal file
@@ -0,0 +1,57 @@
|
||||
--TEST--
|
||||
GH-16514: Nested generator in zend_test observer
|
||||
--EXTENSIONS--
|
||||
zend_test
|
||||
--INI--
|
||||
zend_test.observer.enabled=1
|
||||
zend_test.observer.show_init_backtrace=1
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Foo {
|
||||
public function __destruct() {
|
||||
debug_print_backtrace();
|
||||
}
|
||||
}
|
||||
function bar() {
|
||||
yield from foo();
|
||||
}
|
||||
function foo() {
|
||||
$foo = new Foo();
|
||||
yield;
|
||||
}
|
||||
$gen = bar();
|
||||
foreach ($gen as $dummy);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
<!-- init '%sgh16514.php' -->
|
||||
<!--
|
||||
{main} %sgh16514.php
|
||||
-->
|
||||
<!-- init bar() -->
|
||||
<!--
|
||||
bar()
|
||||
{main} %sgh16514.php
|
||||
-->
|
||||
<!-- init foo() -->
|
||||
<!--
|
||||
foo()
|
||||
bar()
|
||||
{main} %sgh16514.php
|
||||
-->
|
||||
<!-- init Foo::__destruct() -->
|
||||
<!--
|
||||
Foo::__destruct()
|
||||
bar()
|
||||
{main} %sgh16514.php
|
||||
-->
|
||||
<!-- init debug_print_backtrace() -->
|
||||
<!--
|
||||
debug_print_backtrace()
|
||||
Foo::__destruct()
|
||||
bar()
|
||||
{main} %sgh16514.php
|
||||
-->
|
||||
#0 %s(%d): Foo->__destruct()
|
||||
#1 %s(%d): bar()
|
||||
Reference in New Issue
Block a user