Skip to content

Commit

Permalink
Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Jul 21, 2021
1 parent a089386 commit a9991fb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ PHP NEWS
Nikita)
. Fixed bug #81272 (Segfault in var[] after array_slice with JIT). (Nikita)
. Fixed Bug #81255 (Memory leak in PHPUnit with functional JIT). (Dmitry)
. Fixed Bug #80959 (infinite loop in building cfg during JIT compilation)
(Nikita, Dmitry)

- Standard:
. Fixed bug #72146 (Integer overflow on substr_replace). (cmb)
Expand Down
4 changes: 4 additions & 0 deletions ext/opcache/Optimizer/zend_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,10 @@ int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg) /* {{{
j = blocks[j].loop_header;
}
if (j != i) {
if (blocks[j].idom < 0 && j != 0) {
/* Ignore blocks that are unreachable or only abnormally reachable. */
continue;
}
blocks[j].loop_header = i;
for (k = 0; k < blocks[j].predecessors_count; k++) {
zend_worklist_push(&work, cfg->predecessors[blocks[j].predecessor_offset + k]);
Expand Down
31 changes: 31 additions & 0 deletions ext/opcache/tests/jit/bug80959.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
Bug #80959: infinite loop in building cfg during JIT compilation
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=1M
opcache.jit=tracing
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
function test($a, $b) {
echo "Start\n";
$i = $j = 0;
do {
$i++;
try {
continue;
} catch (Exception $e) {
}
do {
$j++;
} while ($j < $b);
} while ($i < $a);
echo "Done $i $j\n";
}
test(5, 6);
?>
--EXPECT--
Start
Done 5 0

0 comments on commit a9991fb

Please sign in to comment.