Skip to content
forked from php/php-src

Commit f65144f

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Tracing JIT: Fixed abstract stack consistency for [QM_]ASSIGN of CV to itself
2 parents dca0112 + fc35a6b commit f65144f

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
@@ -6188,7 +6188,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
61886188
ssa->var_info[ssa_op->result_def].has_range = 1;
61896189
}
61906190
}
6191-
if (ssa_op->op1_def >= 0) {
6191+
if (ssa_op->op1_def >= 0
6192+
&& (opline->opcode != ZEND_QM_ASSIGN
6193+
|| opline->result_type != IS_CV
6194+
|| opline->result.var != opline->op1.var)) {
61926195
zend_uchar type = IS_UNKNOWN;
61936196

61946197
if (!(ssa->var_info[ssa_op->op1_def].type & MAY_BE_GUARD)
@@ -6247,7 +6250,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62476250
ssa->var_info[ssa_op->op1_def].has_range = 1;
62486251
}
62496252
}
6250-
if (ssa_op->op2_def >= 0) {
6253+
if (ssa_op->op2_def >= 0
6254+
&& (opline->opcode != ZEND_ASSIGN
6255+
|| opline->op1_type != IS_CV
6256+
|| opline->op1.var != opline->op2.var)) {
62516257
zend_uchar type = IS_UNKNOWN;
62526258

62536259
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)