Skip to content

Commit 99fa723

Browse files
committed
Fix building of callgraph including preloaded symbols
This issue was introduced in phpGH-15021. When building the call graph, we can now see preloaded functions. However, building the call graph involves mutating the callee, which we don't want to do for functions not coming from the script, especially because the call graph is released later on. Fixes phpGH-15490
1 parent 6a51062 commit 99fa723

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Zend/Optimizer/zend_call_graph.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32
7979

8080
if (build_flags & ZEND_CALL_TREE) {
8181
call_info->next_caller = NULL;
82-
} else if (func->type == ZEND_INTERNAL_FUNCTION) {
82+
} else if (func->type == ZEND_INTERNAL_FUNCTION
83+
|| func->op_array.filename != script->filename) {
8384
call_info->next_caller = NULL;
8485
} else {
8586
zend_func_info *callee_func_info = ZEND_FUNC_INFO(&func->op_array);

ext/opcache/tests/jit/gh15490.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
function foo() {
4+
bar();
5+
}
6+
7+
function bar() {
8+
echo 'Hello world!';
9+
}

ext/opcache/tests/jit/gh15490.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Test
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.preload={PWD}/gh15490.inc
8+
opcache.jit=1235
9+
--EXTENSIONS--
10+
opcache
11+
--FILE--
12+
<?php
13+
14+
foo();
15+
16+
?>
17+
--EXPECT--

0 commit comments

Comments
 (0)