Skip to content
forked from php/php-src

Commit 80d2ade

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Tracing JIT: Fixed abstract stack consistency for [QM_]ASSIGN of CV to itself
2 parents 24d0e21 + f65144f commit 80d2ade

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
@@ -6201,7 +6201,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62016201
ssa->var_info[ssa_op->result_def].has_range = 1;
62026202
}
62036203
}
6204-
if (ssa_op->op1_def >= 0) {
6204+
if (ssa_op->op1_def >= 0
6205+
&& (opline->opcode != ZEND_QM_ASSIGN
6206+
|| opline->result_type != IS_CV
6207+
|| opline->result.var != opline->op1.var)) {
62056208
zend_uchar type = IS_UNKNOWN;
62066209

62076210
if (!(ssa->var_info[ssa_op->op1_def].type & MAY_BE_GUARD)
@@ -6260,7 +6263,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62606263
ssa->var_info[ssa_op->op1_def].has_range = 1;
62616264
}
62626265
}
6263-
if (ssa_op->op2_def >= 0) {
6266+
if (ssa_op->op2_def >= 0
6267+
&& (opline->opcode != ZEND_ASSIGN
6268+
|| opline->op1_type != IS_CV
6269+
|| opline->op1.var != opline->op2.var)) {
62646270
zend_uchar type = IS_UNKNOWN;
62656271

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