Skip to content

Commit 079c5af

Browse files
committed
JIT: Fix register allocation
Fixes oss-fuzz #43598
1 parent f7c3f6e commit 079c5af

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3075,7 +3075,9 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
30753075
intervals[use]->used_as_hint = NULL;
30763076
intervals[use]->list_next = NULL;
30773077
}
3078-
} else if (intervals[use] && !ssa->vars[phi->ssa_var].no_val) {
3078+
} else if (intervals[use]
3079+
&& (!ssa->vars[def].no_val
3080+
|| ssa->var_info[def].type != ssa->var_info[use].type)) {
30793081
if (ssa->vars[use].use_chain >= 0) {
30803082
intervals[use]->flags |= ZREG_STORE;
30813083
} else {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Register Alloction 006: 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+
--FILE--
9+
<?php
10+
function foo() {
11+
$a = 0;
12+
for($i=0; $i < 6; $i++) {
13+
$y - $b = $a ? $b : $y;
14+
$a = $b = 7;
15+
}
16+
}
17+
foo()
18+
?>
19+
DONE
20+
--EXPECTF--
21+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
22+
23+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
24+
25+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
26+
27+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
28+
29+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
30+
31+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
32+
33+
Warning: Undefined variable $y in %sreg_alloc_006.php on line 5
34+
DONE

0 commit comments

Comments
 (0)