Skip to content

Commit e79dbe1

Browse files
committed
JIT: Fix crash during compilation of function with incompletely constructed SSA
Fixes oss-fuzz #42200
1 parent c435e67 commit e79dbe1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
23112311
}
23122312
end = ssa->cfg.blocks[b].start + ssa->cfg.blocks[b].len - 1;
23132313
for (i = ssa->cfg.blocks[b].start; i <= end; i++) {
2314-
zend_ssa_op *ssa_op = &ssa->ops[i];
2314+
zend_ssa_op *ssa_op = ssa->ops ? &ssa->ops[i] : NULL;
23152315
opline = op_array->opcodes + i;
23162316
switch (opline->opcode) {
23172317
case ZEND_INIT_FCALL:
@@ -2342,6 +2342,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
23422342
res_use_info = -1;
23432343

23442344
if (opline->result_type == IS_CV
2345+
&& ssa->vars
23452346
&& ssa_op->result_use >= 0
23462347
&& !ssa->vars[ssa_op->result_use].no_val) {
23472348
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
@@ -2406,6 +2407,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
24062407
res_use_info = -1;
24072408

24082409
if (opline->result_type == IS_CV
2410+
&& ssa->vars
24092411
&& ssa_op->result_use >= 0
24102412
&& !ssa->vars[ssa_op->result_use].no_val) {
24112413
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
@@ -2463,6 +2465,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
24632465
res_use_info = -1;
24642466

24652467
if (opline->result_type == IS_CV
2468+
&& ssa->vars
24662469
&& ssa_op->result_use >= 0
24672470
&& !ssa->vars[ssa_op->result_use].no_val) {
24682471
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();

ext/opcache/tests/jit/mod_006.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
JIT MOD: 005
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(){
12+
$a = 1;
13+
$b = $a % 0;
14+
yield $b;
15+
}
16+
?>
17+
DONE
18+
--EXPECT--
19+
DONE

0 commit comments

Comments
 (0)