Skip to content

Commit 7cf6f17

Browse files
committedJun 29, 2022
Fixed bug GH-8847 (PHP hanging infinitly at 100% cpu when check php syntaxe of a valid file)
1 parent 325ca31 commit 7cf6f17

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed
 

‎NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ PHP NEWS
1313
. Fixed bug GH-8848 (imagecopyresized() error refers to the wrong argument).
1414
(cmb)
1515

16+
- OPcache:
17+
. Fixed bug GH-8847 (PHP hanging infinitly at 100% cpu when check php
18+
syntaxe of a valid file). (Dmitry)
19+
1620
07 Jul 2022, PHP 8.0.21
1721

1822
- Core:

‎ext/opcache/jit/zend_jit.c

+9-13
Original file line numberDiff line numberDiff line change
@@ -1098,22 +1098,18 @@ static void zend_jit_add_hint(zend_lifetime_interval **intervals, int dst, int s
10981098
src = dst;
10991099
dst = tmp;
11001100
}
1101-
while (1) {
1102-
if (intervals[dst]->hint) {
1103-
if (intervals[dst]->hint->range.start < intervals[src]->range.start) {
1104-
int tmp = src;
1105-
src = intervals[dst]->hint->ssa_var;
1106-
dst = tmp;
1107-
} else {
1108-
dst = intervals[dst]->hint->ssa_var;
1109-
}
1101+
while (dst != src && intervals[dst]->hint) {
1102+
if (intervals[dst]->hint->range.start < intervals[src]->range.start) {
1103+
int tmp = src;
1104+
src = intervals[dst]->hint->ssa_var;
1105+
dst = tmp;
11101106
} else {
1111-
if (dst != src) {
1112-
intervals[dst]->hint = intervals[src];
1113-
}
1114-
return;
1107+
dst = intervals[dst]->hint->ssa_var;
11151108
}
11161109
}
1110+
if (dst == src) {
1111+
intervals[dst]->hint = intervals[src];
1112+
}
11171113
}
11181114

11191115
/* See "Linear Scan Register Allocation on SSA Form", Christian Wimmer and

‎ext/opcache/tests/jit/gh8847.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug GH-8847: PHP hanging infinitly at 100% cpu when check php syntaxe of a valid file
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
class klass
11+
{
12+
public function method(int $int, bool $bool=false) : int
13+
{
14+
while($int >= 0 && !$function1)
15+
$int--;
16+
if($bool)
17+
while($int >= 0 && $function1)
18+
$int--;
19+
return $int;
20+
}
21+
}
22+
?>
23+
DONE
24+
--EXPECTF--
25+
DONE

0 commit comments

Comments
 (0)