-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Incorrect arithmetic calculations when using JIT (2) #10271
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
Comments
it seems that it is not possible to make more expressions. function test() {
$num = 0.005909845561;
$num = ($num) + (1);
if(2.0 > $num && $num > 1.0) {
echo 'ok' . PHP_EOL;
}
printf('%0.12F', $num);
// 973.720730503048
return (968.000000000000) * ($num);
}
ini_set('precision', -1);
ini_set('serialize_precision', -1);
var_dump(test());
?> |
@hormus Is there any setting that can increase the number of expressions that can be executed? I am determined to help fix this bug as it undermines my calculations. I tested behaviour when changing following configuration parameters, with no effect on result (eg. problem still exists):
Changing configuration parameters of The function debug information when set opcache.opt_debug_level=1
|
Here is a code that reproduces the issue: <?php
$tang['KSI']=-9.1751656444142E-5;
$tang['ETA']=8.5076090069491E-5;
$sol['X']['k']=-222.45470924306;
$sol['X']['e']=-8.1787760034414;
$sol['X'][1]=-0.020231298698539;
$sol['Y']['k']=-14.400586941152;
$sol['Y']['e']=392.95090925357;
$sol['Y'][1]=-0.035664413413272;
$sol['xc']=968;
$sol['yc']=548;
for( $p=0; $p<1000; $p++ )
{
print($p.': ');
Tangential2XY($tang,$sol);
}
function Tangential2XY(array $tang, array $sol) : array
{
$x = $sol['X']['k']*$tang['KSI'] + $sol['X']['e']*$tang['ETA'] + $sol['X'][1];
$y = $sol['Y']['k']*$tang['KSI'] + $sol['Y']['e']*$tang['ETA'] + $sol['Y'][1];
printf("In;%.12f;%.12f;%.12f;%.12f;",$x,$y,$sol['xc'],$sol['yc']);
$x = $sol['xc']*($x+1);
$y = $sol['yc']*($y+1);
printf("Out;%.12f;%.12f\n",$x,$y);
if( $x<100 )
exit("Mamy to!\n");
return ['x'=>$x,'y'=>$y];
}
?> The output is:
So the problem came with 65th execution of the function. $sol['xc']=968.0;
$sol['yc']=548.0; eliminates the problem. |
I can repro that also on current master. |
I confirm this and will work on a fix. |
* PHP-8.1: Fix GH-10271: Incorrect arithmetic calculations when using JIT
* PHP-8.2: Fix GH-10271: Incorrect arithmetic calculations when using JIT
Description
EDIT: The test to reproduce the issue is in the comment below: #10271 (comment)
This bug is the same as #10195. The previous ticket was closed because it has not been confirmed in 8.1.13 (by my mistake - zend extenstion not configured correctlyin php.ini). After repeating with the correct setting, the issue appeared.
Additional informations: tests showed that the value of $sol['xc'] and $sol['yc'] variables in line 6 and 7 below behave as they were both equal =1 (and in fact are not!).
The above code produces when JIT enabled:
In;0.005909845561;0.003134992878;968.000000000000;548.000000000000;Out;1.005909845561;1.003134992878
...and when JIT disabled (correct values):
In;0.005909845561;0.003134992878;968.000000000000;548.000000000000;Out;973.720730502727;549.717976097410
It is important to mention that sometimes the same function works correctly, however it's not random - the problem appears exactly in the same place of code execution. From other hand skipping part of the unrelated code causes the problem appears in another place or doesn't appear at all.
PHP Version
PHP 8.1.13
Operating System
Windows 10
The text was updated successfully, but these errors were encountered: