Skip to content

Commit c2b704b

Browse files
committed
Fixed code generation for CMP
Fixes oss-fuzz #63569
1 parent c163ff6 commit c2b704b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6952,6 +6952,10 @@ static int zend_jit_cmp(zend_jit_ctx *jit,
69526952
} else {
69536953
ir_MERGE_N(n, end_inputs->refs);
69546954
}
6955+
} else if (smart_branch_opcode && !exit_addr) {
6956+
/* dead code */
6957+
_zend_jit_add_predecessor_ref(jit, target_label, jit->b, ir_END());
6958+
jit->b = -1;
69556959
}
69566960

69576961
return 1;

ext/opcache/tests/jit/cmp_009.phpt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
--TEST--
2+
JIT CMP: 009 Wrong code generation for dead compare
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+
$j = 0;
12+
for ($i = 0; $i < 20; $j++) {
13+
$a&=
14+
$a = $a.+
15+
$tojenthiss[$i = $v] = $s=
16+
$tojenthiss[$i = $v] = $s=
17+
$a&=
18+
$b =
19+
$b =
20+
$a = $a.+
21+
$obj->prop =
22+
$a = $a.+
23+
$obj->prop =
24+
$a = $a.+
25+
$Sojenthiss[$i = $v] = $s=
26+
$x!= $a ?: $c;
27+
$x!= $a ?: $c;
28+
$x!= $a ?: $c;
29+
$x!= $a ?: $c;
30+
$aZ = $a;
31+
$aZ = $a;
32+
$aZ = $a;
33+
$a = $a.+
34+
$a = $a.+
35+
$x!= $a ?: $c;
36+
$aZ = $a;
37+
$a = $a.+
38+
$a = $a.+
39+
$obj->prop =
40+
$a = $a.+
41+
$Sojenthiss[$i = $v] = $s=
42+
$x!= $a ?: $c;
43+
$x!= $a ?: $c;
44+
$aZ = $a;
45+
}
46+
}
47+
@test();
48+
?>
49+
--EXPECTF--
50+
Fatal error: Uncaught Error: Attempt to assign property "prop" on null in %scmp_009.php:15
51+
Stack trace:
52+
#0 %scmp_009.php(39): test()
53+
#1 {main}
54+
thrown in %scmp_009.php on line 15

0 commit comments

Comments
 (0)