summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-03-25 17:31:33 +0300
committerDmitry Stogov <dmitry@zend.com>2020-03-25 17:31:33 +0300
commit91ee85c20c29fdf8750dbbf22cec998382318620 (patch)
treebdd54fef14a59a02f0b47e8de2f3e8ec7719764e
parent2b3b7f5cd97f3fdcd4fcaada212101975a289d06 (diff)
parent65120cfc0969fe9ebd3d4d659b610a54a35ae026 (diff)
downloadphp-git-91ee85c20c29fdf8750dbbf22cec998382318620.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
-rw-r--r--NEWS4
-rw-r--r--ext/opcache/Optimizer/zend_inference.c19
-rw-r--r--ext/opcache/tests/bug79412.phpt25
3 files changed, 45 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index c5a5cad99c..c85183048a 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,10 @@ PHP NEWS
- Iconv:
. Fixed bug #79200 (Some iconv functions cut Windows-1258). (cmb)
+- OPcache:
+ . Fixed bug #79412 (Opcache chokes and uses 100% CPU on specific script).
+ (Dmitry)
+
- SimpleXML:
. Fixed bug #61597 (SXE properties may lack attributes and content). (cmb)
diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c
index eeec206c0c..fa494794cb 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -1797,12 +1797,25 @@ static int zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* {{
}
} WHILE_WORKLIST_END();
- /* Add all SCC entry variables into worklist for narrowing */
+ /* initialize missing ranges */
for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) {
if (!ssa->var_info[j].has_range) {
zend_inference_init_range(op_array, ssa, j, 1, ZEND_LONG_MIN, ZEND_LONG_MAX, 1);
- } else if (ssa->vars[j].definition_phi &&
- ssa->vars[j].definition_phi->pi < 0) {
+ FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR);
+ }
+ }
+
+ /* widening (second round) */
+ WHILE_WORKLIST(worklist, worklist_len, j) {
+ if (zend_ssa_range_widening(op_array, ssa, j, scc)) {
+ FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR);
+ }
+ } WHILE_WORKLIST_END();
+
+ /* Add all SCC entry variables into worklist for narrowing */
+ for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) {
+ if (ssa->vars[j].definition_phi
+ && ssa->vars[j].definition_phi->pi < 0) {
/* narrowing Phi functions first */
zend_ssa_range_narrowing(op_array, ssa, j, scc);
}
diff --git a/ext/opcache/tests/bug79412.phpt b/ext/opcache/tests/bug79412.phpt
new file mode 100644
index 0000000000..20fb0a5ba9
--- /dev/null
+++ b/ext/opcache/tests/bug79412.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #79412 (Opcache chokes and uses 100% CPU on specific script)
+--INI--
+opcache.enable=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$limitPerRun = 10;
+foreach ($foo as $bar) {
+ $count = 0;
+ foreach ($runs as $run) {
+ ++$count;
+ if ($count >= $limitPerRun) {
+ break;
+ }
+ }
+ foo($limitPerRun);
+}
+?>
+--EXPECTF--
+Notice: Undefined variable: foo in %s on line %d
+
+Warning: Invalid argument supplied for foreach() in %s on line %d