Skip to content

Commit 3e13f16

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fix crash during compilation of function with incompletely constructed SSA
2 parents 1d54097 + 1f03deb commit 3e13f16

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
@@ -2879,7 +2879,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
28792879
}
28802880
end = ssa->cfg.blocks[b].start + ssa->cfg.blocks[b].len - 1;
28812881
for (i = ssa->cfg.blocks[b].start; i <= end; i++) {
2882-
zend_ssa_op *ssa_op = &ssa->ops[i];
2882+
zend_ssa_op *ssa_op = ssa->ops ? &ssa->ops[i] : NULL;
28832883
opline = op_array->opcodes + i;
28842884
switch (opline->opcode) {
28852885
case ZEND_INIT_FCALL:
@@ -2910,6 +2910,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
29102910
res_use_info = -1;
29112911

29122912
if (opline->result_type == IS_CV
2913+
&& ssa->vars
29132914
&& ssa_op->result_use >= 0
29142915
&& !ssa->vars[ssa_op->result_use].no_val) {
29152916
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
@@ -2970,6 +2971,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
29702971
res_use_info = -1;
29712972

29722973
if (opline->result_type == IS_CV
2974+
&& ssa->vars
29732975
&& ssa_op->result_use >= 0
29742976
&& !ssa->vars[ssa_op->result_use].no_val) {
29752977
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
@@ -3023,6 +3025,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
30233025
res_use_info = -1;
30243026

30253027
if (opline->result_type == IS_CV
3028+
&& ssa->vars
30263029
&& ssa_op->result_use >= 0
30273030
&& !ssa->vars[ssa_op->result_use].no_val) {
30283031
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)