Skip to content

Commit bf1a24e

Browse files
committed
Fix GH-17140 (Assertion failure in JIT trace exit with ZEND_FETCH_DIM_FUNC_ARG)
ZEND_FETCH_DIM_FUNC_ARG should also be repeated on undefined access, consistent to how ZEND_FETCH_DIM_R is handled. The opcode was just missing from the assertion list.
1 parent b86308c commit bf1a24e

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8585,7 +8585,7 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
85858585
if (op->opcode == ZEND_FETCH_DIM_IS || op->opcode == ZEND_FETCH_OBJ_IS) {
85868586
ZVAL_NULL(EX_VAR_NUM(i));
85878587
} else {
8588-
assert(op->opcode == ZEND_FETCH_DIM_R || op->opcode == ZEND_FETCH_LIST_R || op->opcode == ZEND_FETCH_OBJ_R);
8588+
assert(op->opcode == ZEND_FETCH_DIM_R || op->opcode == ZEND_FETCH_LIST_R || op->opcode == ZEND_FETCH_OBJ_R || op->opcode == ZEND_FETCH_DIM_FUNC_ARG);
85898589
repeat_last_opline = 1;
85908590
}
85918591
} else {

ext/opcache/tests/jit/gh17140.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
GH-17140 (Assertion failure in JIT trace exit with ZEND_FETCH_DIM_FUNC_ARG)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.jit=1254
7+
opcache.jit_buffer_size=32M
8+
opcache.jit_hot_func=1
9+
opcache.jit_hot_side_exit=1
10+
--FILE--
11+
<?php
12+
namespace Foo;
13+
function test() {
14+
$a['x'][1] = true;
15+
for ($fusion = 0; $i < 3; $i++) {
16+
var_dump($a['x'][0]);
17+
}
18+
}
19+
test();
20+
?>
21+
--EXPECTF--
22+
Warning: Undefined variable $i in %s on line %d
23+
24+
Warning: Undefined array key 0 in %s on line %d
25+
NULL
26+
27+
Warning: Undefined variable $i in %s on line %d
28+
29+
Warning: Undefined array key 0 in %s on line %d
30+
NULL
31+
32+
Warning: Undefined array key 0 in %s on line %d
33+
NULL

0 commit comments

Comments
 (0)