Skip to content

Commit 7e32033

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fixed bug GH-8847 (PHP hanging infinitly at 100% cpu when check php syntaxe of a valid file)
2 parents 9bae9ab + b769336 commit 7e32033

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,22 +1656,18 @@ static void zend_jit_add_hint(zend_lifetime_interval **intervals, int dst, int s
16561656
src = dst;
16571657
dst = tmp;
16581658
}
1659-
while (1) {
1660-
if (intervals[dst]->hint) {
1661-
if (intervals[dst]->hint->range.start < intervals[src]->range.start) {
1662-
int tmp = src;
1663-
src = intervals[dst]->hint->ssa_var;
1664-
dst = tmp;
1665-
} else {
1666-
dst = intervals[dst]->hint->ssa_var;
1667-
}
1659+
while (dst != src && intervals[dst]->hint) {
1660+
if (intervals[dst]->hint->range.start < intervals[src]->range.start) {
1661+
int tmp = src;
1662+
src = intervals[dst]->hint->ssa_var;
1663+
dst = tmp;
16681664
} else {
1669-
if (dst != src) {
1670-
intervals[dst]->hint = intervals[src];
1671-
}
1672-
return;
1665+
dst = intervals[dst]->hint->ssa_var;
16731666
}
16741667
}
1668+
if (dst == src) {
1669+
intervals[dst]->hint = intervals[src];
1670+
}
16751671
}
16761672

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

ext/opcache/tests/jit/gh8847.phpt

Lines changed: 25 additions & 0 deletions
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)