Fix backtraces with overridden zend_execute_ex

This commit is contained in:
Nikita Popov 2021-09-29 16:22:48 +02:00
parent 96ac919957
commit 018ddba9ae
2 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,30 @@
--TEST--
bug_debug_backtrace.phpt with replaced zend_execute_ex
--EXTENSIONS--
zend_test
--INI--
zend_test.replace_zend_execute_ex=1
--FILE--
<?php
function foo() {
bar();
}
function bar() {
boo();
}
function boo(){
debug_print_backtrace();
}
eval("foo();");
echo "Done\n";
?>
--EXPECTF--
#0 %s(%d): boo()
#1 %s(%d): bar()
#2 %s(%d) : eval()'d code(1): foo()
#3 %s(%d): eval()
Done

View file

@ -1820,7 +1820,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp); zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
skip_frame: skip_frame:
if (UNEXPECTED((ZEND_CALL_INFO(call) & ZEND_CALL_TOP_FUNCTION) != 0) if (UNEXPECTED(ZEND_CALL_KIND(call) == ZEND_CALL_TOP_FUNCTION)
&& !fake_frame && !fake_frame
&& prev && prev
&& prev->func && prev->func