Skip to content

Commit a9991fb

Browse files
committed
Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
1 parent a089386 commit a9991fb

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ PHP NEWS
2020
Nikita)
2121
. Fixed bug #81272 (Segfault in var[] after array_slice with JIT). (Nikita)
2222
. Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT). (Dmitry)
23+
. Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
24+
(Nikita, Dmitry)
2325

2426
- Standard:
2527
. Fixed bug #72146 (Integer overflow on substr_replace). (cmb)

ext/opcache/Optimizer/zend_cfg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,10 @@ int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg) /* {{{
890890
j = blocks[j].loop_header;
891891
}
892892
if (j != i) {
893+
if (blocks[j].idom < 0 && j != 0) {
894+
/* Ignore blocks that are unreachable or only abnormally reachable. */
895+
continue;
896+
}
893897
blocks[j].loop_header = i;
894898
for (k = 0; k < blocks[j].predecessors_count; k++) {
895899
zend_worklist_push(&work, cfg->predecessors[blocks[j].predecessor_offset + k]);

ext/opcache/tests/jit/bug80959.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Bug #80959: infinite loop in building cfg during JIT compilation
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit_buffer_size=1M
7+
opcache.jit=tracing
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
function test($a, $b) {
13+
echo "Start\n";
14+
$i = $j = 0;
15+
do {
16+
$i++;
17+
try {
18+
continue;
19+
} catch (Exception $e) {
20+
}
21+
do {
22+
$j++;
23+
} while ($j < $b);
24+
} while ($i < $a);
25+
echo "Done $i $j\n";
26+
}
27+
test(5, 6);
28+
?>
29+
--EXPECT--
30+
Start
31+
Done 5 0

0 commit comments

Comments
 (0)