Commit 4b4e00977a5 for php
commit 4b4e00977a5f09ca0945d7646e737920b2f4759e
Author: David Carlier <devnexen@gmail.com>
Date: Fri Dec 4 04:35:06 2026 +0000
ext/opcache: zend_jit_trace() jumps via stale IP on hooked FETCH_OBJ_FUNC_ARG
Fix GH-26048
A trace stopping at a property hook call inlined FETCH_OBJ_FUNC_ARG, then
returned to the VM through IP, still holding the INIT_METHOD_CALL frame.
Use the VM handler for that trace end instead.
Close GH-26057
diff --git a/NEWS b/NEWS
index a8f6318dcde..6a34ae5b1ea 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ PHP NEWS
- Opcache:
. Fixed type inference of JIT trace after FE_FETCH_R[W] with identical
branches. (ilutov, Arnaud)
+ . Fixed bug GH-26048 (Tracing JIT: segfault when a hooked property is passed
+ as an argument to a run-time-resolved call (FETCH_OBJ_FUNC_ARG) in a hot
+ loop). (David Carlier)
- Standard:
. Fixed bug GH-25959 ("consumed" stream filter loses or repeats data).
diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c
index ceeb2157f35..ca3b087b39d 100644
--- a/ext/opcache/jit/zend_jit_trace.c
+++ b/ext/opcache/jit/zend_jit_trace.c
@@ -6055,7 +6055,9 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer,
if (!JIT_G(current_frame)
|| !JIT_G(current_frame)->call
|| !JIT_G(current_frame)->call->func
- || !TRACE_FRAME_IS_LAST_SEND_BY_VAL(JIT_G(current_frame)->call)) {
+ || !TRACE_FRAME_IS_LAST_SEND_BY_VAL(JIT_G(current_frame)->call)
+ || ((p+1)->op == ZEND_JIT_TRACE_END
+ && (p+1)->stop == ZEND_JIT_TRACE_STOP_PROP_HOOK_CALL)) {
break;
}
ZEND_FALLTHROUGH;
diff --git a/ext/opcache/tests/jit/gh26048.phpt b/ext/opcache/tests/jit/gh26048.phpt
new file mode 100644
index 00000000000..233bc650c7c
--- /dev/null
+++ b/ext/opcache/tests/jit/gh26048.phpt
@@ -0,0 +1,46 @@
+--TEST--
+GH-26048 (zend_jit_trace() segfault on a hooked property passed to a run-time resolved call)
+--CREDITS--
+LordSalmon
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.jit_buffer_size=64M
+opcache.jit=tracing
+opcache.jit_hot_loop=64
+opcache.jit_hot_func=127
+opcache.jit_hot_return=8
+opcache.jit_hot_side_exit=8
+--FILE--
+<?php
+
+class Model {
+ public $hooked {
+ get => 5;
+ }
+}
+
+class Manager {
+ function check($value) {
+ return $value !== null;
+ }
+}
+
+function run($manager, $model) {
+ $count = 0;
+ for ($i = 0; $i < 500; $i++) {
+ if ($manager->check($model->hooked)) {
+ $count++;
+ }
+ }
+ return $count;
+}
+
+var_dump(run(new Manager(), new Model()));
+
+?>
+--EXPECT--
+int(500)