Skip to content

Commit 1f03deb

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

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
@@ -2893,7 +2893,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
28932893
}
28942894
end = ssa->cfg.blocks[b].start + ssa->cfg.blocks[b].len - 1;
28952895
for (i = ssa->cfg.blocks[b].start; i <= end; i++) {
2896-
zend_ssa_op *ssa_op = &ssa->ops[i];
2896+
zend_ssa_op *ssa_op = ssa->ops ? &ssa->ops[i] : NULL;
28972897
opline = op_array->opcodes + i;
28982898
switch (opline->opcode) {
28992899
case ZEND_INIT_FCALL:
@@ -2924,6 +2924,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
29242924
res_use_info = -1;
29252925

29262926
if (opline->result_type == IS_CV
2927+
&& ssa->vars
29272928
&& ssa_op->result_use >= 0
29282929
&& !ssa->vars[ssa_op->result_use].no_val) {
29292930
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
@@ -2984,6 +2985,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
29842985
res_use_info = -1;
29852986

29862987
if (opline->result_type == IS_CV
2988+
&& ssa->vars
29872989
&& ssa_op->result_use >= 0
29882990
&& !ssa->vars[ssa_op->result_use].no_val) {
29892991
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
@@ -3037,6 +3039,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
30373039
res_use_info = -1;
30383040

30393041
if (opline->result_type == IS_CV
3042+
&& ssa->vars
30403043
&& ssa_op->result_use >= 0
30413044
&& !ssa->vars[ssa_op->result_use].no_val) {
30423045
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)