-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fixes for sanitizer errors from SPEC CPU testing #7697
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
base: main
Are you sure you want to change the base?
Conversation
lib/vf_common.cpp:115:96: runtime error: shift exponent 18446744073709550144 is too large for 64-bit type 'long long unsigned int' lib/vf_common.cpp:116:47: runtime error: shift exponent 1919 is too large for 64-bit type 'long long unsigned int'
lib/token.cpp:1949:20: runtime error: signed integer overflow: -9223372036854775808 - 9223372032559808511 cannot be represented in type 'long long int'
lib/infer.cpp:131:39: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long long int' lib/infer.cpp:141:39: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long long int' lib/infer.cpp:322:65: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long long int'
In addition, there are some final errors that I don't know how to fix.
I tried the following to cap the value at the limits, but this led to regressions and failures in testrunner. If someone has a better idea, please share. Thank you.
|
if (std::numeric_limits<long long>::max() == minValue->intvalue) | ||
result.setMinValue(minValue->intvalue, minValue); | ||
else | ||
result.setMinValue(minValue->intvalue + 1, minValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if not doing the addition still leads to a useful value, or if we should bail out somehow for LLONG_MAX
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pfultz2 Maybe you have some insights?
|
|
@@ -101,6 +102,9 @@ namespace ValueFlow | |||
if (value_size == 0) | |||
return value; | |||
|
|||
// sizeof(long long) = 8 | |||
value_size = std::min(sizeof(MathLib::bigint), value_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the feeling we want to be able to truncate according to sizeof(int) here. I.e. the result of ~0U + 2U
should be 1.
We're doing some sanitizer testing on the source code here at SPEC, and I was able to offer some patches to correct the overflow issues. These are corner cases so maybe the cppcheck community may not be so keen to accept these, but I figured I would share.