Skip to content

Commit a3a74b0

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
2 parents 7b85d3b + a9991fb commit a3a74b0

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
@@ -4,6 +4,8 @@ PHP NEWS
44

55
- Opcache:
66
. Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT)
7+
. Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
8+
(Nikita, Dmitry)
79

810
22 Jul 2021, PHP 8.1.0beta1
911

Zend/Optimizer/zend_cfg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,10 @@ ZEND_API int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cf
893893
j = blocks[j].loop_header;
894894
}
895895
if (j != i) {
896+
if (blocks[j].idom < 0 && j != 0) {
897+
/* Ignore blocks that are unreachable or only abnormally reachable. */
898+
continue;
899+
}
896900
blocks[j].loop_header = i;
897901
for (k = 0; k < blocks[j].predecessors_count; k++) {
898902
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)