Skip to content

Commit 2104097

Browse files
nielsdosdstogov
andcommitted
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. Closes GH-17148. Co-authored-by: Dmitry Stogov <dmitry@zend.com>
1 parent 7b2b2ec commit 2104097

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ PHP NEWS
4343

4444
- Opcache:
4545
. opcache_get_configuration() properly reports jit_prof_threshold. (cmb)
46+
. Fixed bug GH-17140 (Assertion failure in JIT trace exit with
47+
ZEND_FETCH_DIM_FUNC_ARG). (nielsdos, Dmitry)
4648

4749
- PCNTL:
4850
. Fix memory leak in cleanup code of pcntl_exec() when a non stringable

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+
ZEND_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 || op->opcode == ZEND_FETCH_OBJ_FUNC_ARG);
85898589
repeat_last_opline = 1;
85908590
}
85918591
} else {

ext/opcache/tests/jit/gh17140_1.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

ext/opcache/tests/jit/gh17140_2.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
GH-17140 (Assertion failure in JIT trace exit with ZEND_FETCH_OBJ_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+
class X {
14+
public $a = 1;
15+
public $b;
16+
function __construct() {
17+
unset($this->b);
18+
}
19+
}
20+
function test() {
21+
$a['x'] = new X;
22+
for ($fusion = 0; $i < 3; $i++) {
23+
var_dump($a['x']->b);
24+
}
25+
}
26+
test();
27+
?>
28+
--EXPECTF--
29+
Warning: Undefined variable $i in %s on line %d
30+
31+
Warning: Undefined property: Foo\X::$b in %s on line %d
32+
NULL
33+
34+
Warning: Undefined variable $i in %s on line %d
35+
36+
Warning: Undefined property: Foo\X::$b in %s on line %d
37+
NULL
38+
39+
Warning: Undefined property: Foo\X::$b in %s on line %d
40+
NULL

0 commit comments

Comments
 (0)