Skip to content

Commit c1ffd4b

Browse files
committed
Fix GH-15658: Segmentation fault in Zend/zend_vm_execute.h
Implement a minimal ZEND_MATCH handler using a tail call. Closes GH-15782.
1 parent 86ef8d5 commit c1ffd4b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ PHP NEWS
3333
- Opcache:
3434
. Fixed bug GH-15661 (Access null pointer in
3535
Zend/Optimizer/zend_inference.c). (nielsdos)
36+
. Fixed bug GH-15658 (Segmentation fault in Zend/zend_vm_execute.h).
37+
(nielsdos)
3638

3739
- Standard:
3840
. Fixed bug GH-15552 (Signed integer overflow in ext/standard/scanf.c). (cmb)

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)