-
Notifications
You must be signed in to change notification settings - Fork 672
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
Psalm 4.6.2 crashed due to an uncaught Throwable #5363
Comments
Hey @johnny-silverhand, can you reproduce the issue on https://psalm.dev ? |
Oh, tricky, Just to be sure, could you run with --debug-by-line and try to figure out the expression that fail? It seems to be a multiplication between two literal integers that would result into a float (kinda like https://3v4l.org/hjE8h) due to a result too big to fit an integer For reference, the error comes from: psalm/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonDivArithmeticOpAnalyzer.php Line 315 in 7b24552
|
Hello @orklah, I tried with --debug-by-line parameter. After few hours of scanning the command is stand without any output at "Gathering data for forked process". Not sure what is going wrong. |
oh. Can you try again with --threads=1 ? No need to let it run for too long, it should output a lot of debug, but if it's stops and hang, you can terminate the execution, it's not normal |
|
after configure, i got these log
|
@orklah breaks down on this code protected function _fromByteString($size)
{
if (is_numeric($size)) {
return (integer) $size;
}
$type = trim(substr($size, -2));
$value = substr($size, 0, -2);
switch (strtoupper($type)) {
case 'YB':
$value *= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024);
break;
case 'ZB':
$value *= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024);
break;
case 'EB':
$value *= (1024 * 1024 * 1024 * 1024 * 1024 * 1024);
break;
case 'PB':
$value *= (1024 * 1024 * 1024 * 1024 * 1024);
break;
case 'TB':
$value *= (1024 * 1024 * 1024 * 1024);
break;
case 'GB':
$value *= (1024 * 1024 * 1024);
break;
case 'MB':
$value *= (1024 * 1024);
break;
case 'KB':
$value *= 1024;
break;
default:
break;
}
return $value;
} |
Thanks, it's confirmed then: https://3v4l.org/kDgcl This multiplication is way too big to fit into an integer so PHP fallback into a float. I'll try to fix that this afternoon |
Who knew PHP could handle yottabytes 🤯 |
The PR should fix Psalm and help it understands the result is a float. However, I'm not sure how your code would behave if you go beyond 8EB. The result will be a imprecise float and it may cause issues. Maybe you should use bc* functions for this kind of uses. |
PHP 8.0.2 Ubuntu 20.04.2 LTS
The text was updated successfully, but these errors were encountered: