Skip to content

Commit ade0bee

Browse files
committed
Fix GH-15658: Segmentation fault in Zend/zend_vm_execute.h
Implement a minimal ZEND_MATCH handler using a tail call.
1 parent 5fc37b1 commit ade0bee

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
39703970
case ZEND_OP_DATA:
39713971
case ZEND_SWITCH_LONG:
39723972
case ZEND_SWITCH_STRING:
3973+
break;
39733974
case ZEND_MATCH:
3975+
/* We have to exit to the VM because the MATCH handler performs an N-way jump for
3976+
* which we can't generate simple (opcache.jit=1201) JIT code. */
3977+
if (!zend_jit_tail_handler(&dasm_state, opline)) {
3978+
goto jit_failure;
3979+
}
39743980
break;
39753981
case ZEND_JMP:
39763982
if (JIT_G(opt_level) < ZEND_JIT_LEVEL_INLINE) {

ext/opcache/tests/jit/gh15658.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
GH-15658 (Segmentation fault in Zend/zend_vm_execute.h)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.jit=0101
7+
opcache.jit_buffer_size=1024M
8+
--FILE--
9+
<?php
10+
echo match (random_int(1, 2)) {
11+
1, 2 => 'foo',
12+
};
13+
?>
14+
--EXPECT--
15+
foo

0 commit comments

Comments
 (0)