Skip to content
forked from php/php-src

Commit fc35a6b

Browse files
committed
Tracing JIT: Fixed abstract stack consistency for [QM_]ASSIGN of CV to itself
1 parent 85066fd commit fc35a6b

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5904,7 +5904,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
59045904
ssa->var_info[ssa_op->result_def].has_range = 1;
59055905
}
59065906
}
5907-
if (ssa_op->op1_def >= 0) {
5907+
if (ssa_op->op1_def >= 0
5908+
&& (opline->opcode != ZEND_QM_ASSIGN
5909+
|| opline->result_type != IS_CV
5910+
|| opline->result.var != opline->op1.var)) {
59085911
zend_uchar type = IS_UNKNOWN;
59095912

59105913
if (!(ssa->var_info[ssa_op->op1_def].type & MAY_BE_GUARD)
@@ -5963,7 +5966,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
59635966
ssa->var_info[ssa_op->op1_def].has_range = 1;
59645967
}
59655968
}
5966-
if (ssa_op->op2_def >= 0) {
5969+
if (ssa_op->op2_def >= 0
5970+
&& (opline->opcode != ZEND_ASSIGN
5971+
|| opline->op1_type != IS_CV
5972+
|| opline->op1.var != opline->op2.var)) {
59675973
zend_uchar type = IS_UNKNOWN;
59685974

59695975
if (!(ssa->var_info[ssa_op->op2_def].type & MAY_BE_GUARD)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
JIT QM_ASSIGN: 002 assign to it self
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function test() {
11+
for ($i = 0; $i < 2; $i++) {
12+
$a = $a;
13+
"-" . $b;
14+
$b = [];
15+
unset($a);
16+
}
17+
}
18+
test();
19+
?>
20+
DONE
21+
--EXPECTF--
22+
Warning: Undefined variable $a in %sqm_assign_002.php on line 4
23+
24+
Warning: Undefined variable $b in %sqm_assign_002.php on line 5
25+
26+
Warning: Undefined variable $a in %sqm_assign_002.php on line 4
27+
28+
Warning: Array to string conversion in %sqm_assign_002.php on line 5
29+
DONE

0 commit comments

Comments
 (0)