-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP hanging infinitly at 100% cpu when check php syntaxe of a valid file #8847
Comments
Confirmed, reproduced in : PHP 8.0.0, PHP 8.1.0, PHP 8.1.4, PHP 8.1.5, PHP 8.1.6, PHP 8.1.7
The JIT configuration seems valid. |
It hangs during JIT compilation in |
To me, it is always a good practice to have exit conditions on while loops. If Something like this (would be time-consuming) : + int counter = 0;
while (1) {
if (intervals[dst]->hint) {
if (intervals[dst]->hint->range.start < intervals[src]->range.start) {
int tmp = src;
src = intervals[dst]->hint->ssa_var;
dst = tmp;
} else {
dst = intervals[dst]->hint->ssa_var;
}
} else {
if (dst != src) {
intervals[dst]->hint = intervals[src];
}
return;
}
+ counter++;
+ if(counter > 2000000000)
+ return; // or throw
} A more memory-consuming way would be to check if the new value of |
From my vague understanding, We call I think that the purpose of php-src/ext/opcache/jit/zend_jit.c Line 1654 in 0429159
php-src/ext/opcache/jit/zend_jit.c Line 1661 in 0429159
However, in the case of We could fallback to comparing ssa vars when range.start are equal. I'm not sure that this is correct, but this fixes the problem for me: diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index 8ed75b7b7c..9cda453992 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -1651,14 +1651,14 @@ static void zend_jit_compute_loop_body(zend_ssa *ssa, int header, int n, zend_bi
static void zend_jit_add_hint(zend_lifetime_interval **intervals, int dst, int src)
{
- if (intervals[dst]->range.start < intervals[src]->range.start) {
+ if (intervals[dst]->range.start < intervals[src]->range.start || (intervals[dst]->range.start == intervals[src]->range.start && dst < src)) {
int tmp = src;
src = dst;
dst = tmp;
}
while (1) {
if (intervals[dst]->hint) {
- if (intervals[dst]->hint->range.start < intervals[src]->range.start) {
+ if (intervals[dst]->hint->range.start < intervals[src]->range.start || (intervals[dst]->hint->range.start == intervals[src]->range.start && intervals[dst]->hint->ssa_var < src)) {
int tmp = src;
src = intervals[dst]->hint->ssa_var;
dst = tmp; |
@arnaud-lb, that sounds plausible. I suggest to submit a PR, and request a review from @dstogov. |
* PHP-8.0: Fixed bug GH-8847 (PHP hanging infinitly at 100% cpu when check php syntaxe of a valid file)
* PHP-8.1: Fixed bug GH-8847 (PHP hanging infinitly at 100% cpu when check php syntaxe of a valid file)
Description
The following code:
Resulted in this output:
But I expected this output instead:
hanging infinitely, can't be canceled, sigkill 6 needed.
use 100% off one cpu
When opcache is disable it's OK
When jit in opcache is disable it's OK
When jit is opcache.jit = 1255 it's OK
when jit is opcache.jit = 1205 its' KO
The zero from 1205 look suspicious
Here the opcache conf
here the output of opcache
=>hanging here
To reproduce with docker, php 8.0.x to 8.1.x
In the console
PHP Version
PHP 8.0.x and 8.1.x
Operating System
Debian
The text was updated successfully, but these errors were encountered: