diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 5f4bd908a5f8..c706f6825035 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -6582,7 +6582,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } } } - if (ssa->var_info[ssa_op->result_def].type & MAY_BE_INDIRECT) { + if ((ssa->var_info[ssa_op->result_def].type & MAY_BE_INDIRECT) + || opline->opcode == ZEND_FETCH_OBJ_R + || opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG + || opline->opcode == ZEND_FETCH_OBJ_IS) { RESET_STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var)); } if (type != IS_UNKNOWN) { diff --git a/ext/opcache/tests/jit/gh25480.phpt b/ext/opcache/tests/jit/gh25480.phpt new file mode 100644 index 000000000000..1b29876e667a --- /dev/null +++ b/ext/opcache/tests/jit/gh25480.phpt @@ -0,0 +1,48 @@ +--TEST-- +GH-25480: Tracing JIT does not reuse stale FETCH_DIM_IS result +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit=tracing +opcache.jit_hot_loop=1 +opcache.jit_buffer_size=16M +--EXTENSIONS-- +opcache +--FILE-- + $row) { + if ($none?->id == $id) {} + $x = $row->a && $row->b; + try { + if (!take($map[$id] ?? [])) { + $bad++; + } + } catch (TypeError $e) { + $bad++; + } + } + return $bad; +} + +$rows = array_fill(0, 100, new Row()); +$bad = 0; +for ($i = 0; $i < 10; $i++) { + $bad += run($rows, [0 => ['present']], null); +} +echo "Bad values: $bad\n"; +?> +--EXPECT-- +Bad values: 0