Skip to content

Commit e30d78f

Browse files
committed
Fixed incorrect guard elimination
Fixes oss-fuzz #64414
1 parent 298bba5 commit e30d78f

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4513,7 +4513,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
45134513
if (((res_info & (MAY_BE_ANY|MAY_BE_GUARD)) == (MAY_BE_LONG|MAY_BE_GUARD)
45144514
|| (res_info & (MAY_BE_ANY|MAY_BE_GUARD)) == (MAY_BE_DOUBLE|MAY_BE_GUARD))
45154515
&& has_concrete_type(op1_info)
4516-
&& has_concrete_type(op2_info)) {
4516+
&& (op1_info & (MAY_BE_LONG|MAY_BE_DOUBLE))
4517+
&& has_concrete_type(op2_info)
4518+
&& (op2_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
45174519
ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
45184520
}
45194521
}

ext/opcache/tests/jit/mul_010.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
JIT MUL: 010 incorrect guard elimination
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--FILE--
7+
<?php
8+
function test() {
9+
$j = 0;
10+
for ($i = 0; $i < 40; $i++) {
11+
$a * $e == $a - $a + $e;
12+
$maq[$obj] = $a + $e;
13+
$maq[$obj] = $maq[$obj] = !!$a = $a .
14+
$maq[$obj] = $maq[$obj] = $maq[$obj] = $maq[$obj] = $a = $a + $a = &$a +
15+
$maq[$obj] = $maq[$obj] = $a + $e;
16+
$maq[$obj] = $maq[$obj] = !!$a = $a . $maq[$obj] = $maq[$obj] = $maq[$obj] =
17+
$maq[$obj] = $a * $e == $a - $a + $e;
18+
$maq[$obj] = $maq[$obj] = +$e;
19+
$a * $e == $a - $a + $e;
20+
+$e;
21+
$a * $a = $a + $a = &$a + $e = $a-- +$a + $e;
22+
$maq[$obj] = $maq[$obj] = !!$a = $a . $a &= $aZ = $a;
23+
}
24+
}
25+
try {
26+
@test();
27+
} catch (Throwable $ex) {
28+
echo $ex->getMessage() . "\n";
29+
}
30+
?>
31+
--EXPECT--
32+
Unsupported operand types: string * float

0 commit comments

Comments
 (0)