Skip to content

Commit 5a05fef

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
2 parents 782f7e2 + 91ee85c commit 5a05fef

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

ext/opcache/Optimizer/zend_inference.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -1787,12 +1787,25 @@ static int zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* {{
17871787
}
17881788
} WHILE_WORKLIST_END();
17891789

1790-
/* Add all SCC entry variables into worklist for narrowing */
1790+
/* initialize missing ranges */
17911791
for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) {
17921792
if (!ssa->var_info[j].has_range) {
17931793
zend_inference_init_range(op_array, ssa, j, 1, ZEND_LONG_MIN, ZEND_LONG_MAX, 1);
1794-
} else if (ssa->vars[j].definition_phi &&
1795-
ssa->vars[j].definition_phi->pi < 0) {
1794+
FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR);
1795+
}
1796+
}
1797+
1798+
/* widening (second round) */
1799+
WHILE_WORKLIST(worklist, worklist_len, j) {
1800+
if (zend_ssa_range_widening(op_array, ssa, j, scc)) {
1801+
FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR);
1802+
}
1803+
} WHILE_WORKLIST_END();
1804+
1805+
/* Add all SCC entry variables into worklist for narrowing */
1806+
for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) {
1807+
if (ssa->vars[j].definition_phi
1808+
&& ssa->vars[j].definition_phi->pi < 0) {
17961809
/* narrowing Phi functions first */
17971810
zend_ssa_range_narrowing(op_array, ssa, j, scc);
17981811
}

ext/opcache/tests/bug79412.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #79412 (Opcache chokes and uses 100% CPU on specific script)
3+
--INI--
4+
opcache.enable=1
5+
opcache.optimization_level=-1
6+
--SKIPIF--
7+
<?php require_once('skipif.inc'); ?>
8+
--FILE--
9+
<?php
10+
$limitPerRun = 10;
11+
foreach ($foo as $bar) {
12+
$count = 0;
13+
foreach ($runs as $run) {
14+
++$count;
15+
if ($count >= $limitPerRun) {
16+
break;
17+
}
18+
}
19+
foo($limitPerRun);
20+
}
21+
?>
22+
--EXPECTF--
23+
Warning: Undefined variable: foo in %s on line %d
24+
25+
Warning: foreach() argument must be of type array|object, null given in %s on line %d

0 commit comments

Comments
 (0)