Skip to content

Commit 91ee85c

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
2 parents 2b3b7f5 + 65120cf commit 91ee85c

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
- Iconv:
1818
. Fixed bug #79200 (Some iconv functions cut Windows-1258). (cmb)
1919

20+
- OPcache:
21+
. Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
22+
(Dmitry)
23+
2024
- SimpleXML:
2125
. Fixed bug #61597 (SXE properties may lack attributes and content). (cmb)
2226

ext/opcache/Optimizer/zend_inference.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,12 +1797,25 @@ static int zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* {{
17971797
}
17981798
} WHILE_WORKLIST_END();
17991799

1800-
/* Add all SCC entry variables into worklist for narrowing */
1800+
/* initialize missing ranges */
18011801
for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) {
18021802
if (!ssa->var_info[j].has_range) {
18031803
zend_inference_init_range(op_array, ssa, j, 1, ZEND_LONG_MIN, ZEND_LONG_MAX, 1);
1804-
} else if (ssa->vars[j].definition_phi &&
1805-
ssa->vars[j].definition_phi->pi < 0) {
1804+
FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR);
1805+
}
1806+
}
1807+
1808+
/* widening (second round) */
1809+
WHILE_WORKLIST(worklist, worklist_len, j) {
1810+
if (zend_ssa_range_widening(op_array, ssa, j, scc)) {
1811+
FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR);
1812+
}
1813+
} WHILE_WORKLIST_END();
1814+
1815+
/* Add all SCC entry variables into worklist for narrowing */
1816+
for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) {
1817+
if (ssa->vars[j].definition_phi
1818+
&& ssa->vars[j].definition_phi->pi < 0) {
18061819
/* narrowing Phi functions first */
18071820
zend_ssa_range_narrowing(op_array, ssa, j, scc);
18081821
}

ext/opcache/tests/bug79412.phpt

Lines changed: 25 additions & 0 deletions
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+
Notice: Undefined variable: foo in %s on line %d
24+
25+
Warning: Invalid argument supplied for foreach() in %s on line %d

0 commit comments

Comments
 (0)