Skip to content

Commit 2727d59

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 2727d59

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,11 @@ 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+
if (zend_jit_tail_handler(&dasm_state, opline)) {
3976+
goto jit_failure;
3977+
}
39743978
break;
39753979
case ZEND_JMP:
39763980
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)