Skip to content

Commit 7a93a8a

Browse files
committed
JIT: Fixed JIT for FETCH_OBJ when op1 is a reference of non-object
1 parent 1985437 commit 7a93a8a

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4285,6 +4285,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42854285
} else {
42864286
CHECK_OP1_TRACE_TYPE();
42874287
}
4288+
if (!(op1_info & MAY_BE_OBJECT)) {
4289+
break;
4290+
}
42884291
if (ssa->var_info && ssa->ops) {
42894292
if (ssa_op->op1_use >= 0) {
42904293
zend_ssa_var_info *op1_ssa = ssa->var_info + ssa_op->op1_use;
@@ -4356,6 +4359,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
43564359
} else {
43574360
CHECK_OP1_TRACE_TYPE();
43584361
}
4362+
if (!(op1_info & MAY_BE_OBJECT)) {
4363+
break;
4364+
}
43594365
if (ssa->var_info && ssa->ops) {
43604366
if (ssa_op->op1_use >= 0) {
43614367
zend_ssa_var_info *op1_ssa = ssa->var_info + ssa_op->op1_use;
@@ -4422,6 +4428,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
44224428
} else {
44234429
CHECK_OP1_TRACE_TYPE();
44244430
}
4431+
if (!(op1_info & MAY_BE_OBJECT)) {
4432+
break;
4433+
}
44254434
if (ssa->var_info && ssa->ops) {
44264435
if (ssa_op->op1_use >= 0) {
44274436
zend_ssa_var_info *op1_ssa = ssa->var_info + ssa_op->op1_use;
@@ -5377,9 +5386,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
53775386
}
53785387
} else {
53795388
CHECK_OP1_TRACE_TYPE();
5380-
if (!(op1_info & MAY_BE_OBJECT)) {
5381-
break;
5382-
}
5389+
}
5390+
if (!(op1_info & MAY_BE_OBJECT)) {
5391+
break;
53835392
}
53845393
if (ssa->var_info && ssa->ops) {
53855394
if (ssa_op->op1_use >= 0) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
JIT: FETCH_OBJ 005
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.jit=tracing
9+
--SKIPIF--
10+
<?php require_once('skipif.inc'); ?>
11+
--FILE--
12+
<?php
13+
for ($i = 0; $i < 3; $i++) {
14+
$a =& $b;
15+
$a->p;
16+
}
17+
?>
18+
--EXPECTF--
19+
Warning: Attempt to read property "p" on null in %sfetch_obj_005.php on line 4
20+
21+
Warning: Attempt to read property "p" on null in %sfetch_obj_005.php on line 4
22+
23+
Warning: Attempt to read property "p" on null in %sfetch_obj_005.php on line 4

0 commit comments

Comments
 (0)