You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a (pretty old) PHP projet, is used a non-typed function moins (minus in french) with this simple following code:
<?phpfunctionmoins($a, $b) {
return$a - $b;
}
We wanted to activate JIT (tracing) on PHP 8.4 (now with PHP 8.4.8), and after some unpredictable minutes or hours (depending of the website traffic ?) , the result of this function moins becomes wrong :
Moins:
0
4.9406564584125E-324
9.8813129168249E-324
with string:
0
4.9406564584125E-324
9.8813129168249E-324
But we expected this output instead:
Moins:
0
1
2
with string:
0
1
2
We didn’t test JIT before on previous PHP branches, so I don’t know if the result is the same on PHP 8.3 or before. This bug doesn’t appear without JIT enabled.
As you can see, some float with exponent is returned, and it seems related with floating point IEEE 754 64-bit binary format ; these numbers are the same as
And with all that, I was unable to reproduce that in CLI with JIT tracing on (we show that with FPM), nor in my local (DDEV) environment (and with different JIT configuration option).
The bug disapear (for some time) as soon as we reload that PHP version.
We show that at least on 2 different servers, with intel CPU
BIOS Model name: Intel(R) Xeon(R) E-2136 CPU @ 3.30GHz To Be Filled By O.E.M. CPU @ 3.3GHz
BIOS Model name: Intel(R) Xeon(R) E-2288G CPU @ 3.70GHz To Be Filled By O.E.M. CPU @ 3.7GHz
Obviously, this moins function is used in a more complex context, in a web templating system notably, that function may also be call inside an eval() (I don’t know if that the cause of the problem) ; but for now I’m not able to reproduce a systematic small file code which trigger the bug, outside the full web project.
But from the moment the function bugs, it bugs in whatever script the function is called (that includes the file with the function declaration).
One example tried among other in CLI to reproduce vainly
This is most likely an issue caused by the combination of FPM and JIT.
Since the problem doesn’t occur when JIT is disabled, it’s likely that the JIT optimization process is conflicting across multiple processes, resulting in corrupted JIT-compiled code.
Would it be possible to try using JIT in function mode instead of tracing?
The tracing mode performs more complex optimizations, which makes it more prone to issues like code corruption compared to function mode.
I can't reproduce the problem.
I suppose the bug is triggered by usage of moins() in some specific context/trace, but I can't guess this.
Function JIT should work, but this won't fix the existing bug.
I would recommend to try the same script/app with PHP debug build (even better ASAN build) and with opcache.protect_memory=1. May be this will show some assertions.
Description
In a (pretty old) PHP projet, is used a non-typed function
moins
(minus in french) with this simple following code:We wanted to activate JIT (tracing) on PHP 8.4 (now with PHP 8.4.8), and after some unpredictable minutes or hours (depending of the website traffic ?) , the result of this function
moins
becomes wrong :Resulted in this output:
But we expected this output instead:
We didn’t test JIT before on previous PHP branches, so I don’t know if the result is the same on PHP 8.3 or before. This bug doesn’t appear without JIT enabled.
As you can see, some float with exponent is returned, and it seems related with floating point IEEE 754 64-bit binary format ; these numbers are the same as
And with all that, I was unable to reproduce that in CLI with JIT tracing on (we show that with FPM), nor in my local (DDEV) environment (and with different JIT configuration option).
The bug disapear (for some time) as soon as we reload that PHP version.
We show that at least on 2 different servers, with intel CPU
Opcache.jit* FPM configuration:
Is it something that talk to someone ?
Obviously, this
moins
function is used in a more complex context, in a web templating system notably, that function may also be call inside aneval()
(I don’t know if that the cause of the problem) ; but for now I’m not able to reproduce a systematic small file code which trigger the bug, outside the full web project.But from the moment the function bugs, it bugs in whatever script the function is called (that includes the file with the function declaration).
One example tried among other in CLI to reproduce vainly
Note: I’m not so familiar with php-src, please apologize if I’m not write things the rigth way.
PHP Version
Operating System
Debian GNU/Linux 12 (bookworm)
The text was updated successfully, but these errors were encountered: