Skip to content

Commit 54c952f

Browse files
committed
JIT: Fix incorrect type store elimination
Fixes oss-fuzz #43737
1 parent f711c96 commit 54c952f

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,14 +4624,16 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
46244624
break;
46254625
}
46264626
op2_addr = OP2_REG_ADDR();
4627+
op2_info = OP2_INFO();
46274628
if (ra
46284629
&& ssa_op->op2_def >= 0
4629-
&& !ssa->vars[ssa_op->op2_def].no_val) {
4630+
&& (!ssa->vars[ssa_op->op2_def].no_val
4631+
|| (zend_jit_trace_type_to_info(STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op2.var))) & MAY_BE_ANY) !=
4632+
(op2_info & MAY_BE_ANY))) {
46304633
op2_def_addr = OP2_DEF_REG_ADDR();
46314634
} else {
46324635
op2_def_addr = op2_addr;
46334636
}
4634-
op2_info = OP2_INFO();
46354637
CHECK_OP2_TRACE_TYPE();
46364638
op1_info = OP1_INFO();
46374639
if ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_GUARD)) == MAY_BE_LONG

ext/opcache/tests/jit/assign_050.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
JIT ASSIGN: incorrect type store elimination
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.protect_memory=1
9+
--FILE--
10+
<?php
11+
function foo($a) {
12+
$b = $a;
13+
$b =! $a = $a + $b & $b & $b = $b = $a = $a + $b & $a += $a;
14+
$b = $b = $a = $a + $b & $b & $b = $a = $a + $b = $b = $a = $a + $b = $a += $a;
15+
}
16+
17+
for ($i = 0; $i < 3; $i++) {
18+
@foo(39087589046889428661);
19+
}
20+
?>
21+
DONE
22+
--EXPECT--
23+
DONE

0 commit comments

Comments
 (0)