Skip to content

Commit a8bbfb8

Browse files
committed
Merge branch 'PHP-8.6'
* PHP-8.6: Fix GH-24388: Tracing JIT segfault when a trace runs out of side exits
2 parents a42c06e + 3f9f09e commit a8bbfb8

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎ext/opcache/jit/zend_jit_ir.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4767,6 +4767,9 @@ static int zend_jit_inc_dec(zend_jit_ctx *jit, const zend_op *opline, uint32_t o
47674767

47684768
exit_point = zend_jit_trace_get_exit_point(opline + 1, 0);
47694769
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
4770+
if (!exit_addr) {
4771+
return 0;
4772+
}
47704773
ir_GUARD_NOT(ir_OVERFLOW(ref), ir_CONST_ADDR(exit_addr));
47714774

47724775
if ((opline->opcode == ZEND_PRE_INC || opline->opcode == ZEND_PRE_DEC) &&
@@ -4808,6 +4811,9 @@ static int zend_jit_inc_dec(zend_jit_ctx *jit, const zend_op *opline, uint32_t o
48084811

48094812
exit_point = zend_jit_trace_get_exit_point(opline + 1, 0);
48104813
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
4814+
if (!exit_addr) {
4815+
return 0;
4816+
}
48114817
ir_GUARD(ir_OVERFLOW(ref), ir_CONST_ADDR(exit_addr));
48124818

48134819
if (opline->result_type != IS_UNUSED) {

‎ext/opcache/tests/jit/gh24388.phpt‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
GH-24388 (Tracing JIT: segfault when a trace runs out of side exits)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=64M
8+
opcache.jit=tracing
9+
--EXTENSIONS--
10+
opcache
11+
--FILE--
12+
<?php
13+
$file = __DIR__ . "/gh24388.inc";
14+
15+
$code = '<?php function f(int $k, int $a) { switch ($k) {';
16+
for ($i = 0; $i < 507; $i++) {
17+
$code .= "case $i: \$l = $i; break;";
18+
}
19+
$code .= '} return ++$a; }';
20+
$code .= 'for ($i = 0; $i < 200; $i++) { $a = 3; f(0, $a); }';
21+
file_put_contents($file, $code);
22+
23+
include $file;
24+
?>
25+
DONE
26+
--CLEAN--
27+
<?php
28+
@unlink(__DIR__ . "/gh24388.inc");
29+
?>
30+
--EXPECT--
31+
DONE

0 commit comments

Comments
 (0)