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
Change Word64 type from long long to unsigned long long #5458
Conversation
The following change is required to solve undefined behavior detected by UBSan. 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:17:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:18:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:19:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:20:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:21:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:22:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:23:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:24:22 405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:25:22 ~Word64(0) is -1 and left shifting a negative number is undefined behavior by C++. These produce 3645 runtime errors from UBSan on full matrix. That's ~15% of all detected runtime errors. Word32 is defined as unsigned type. Keep it consistent and define Word64 as unsigned long long, thus resolved undefined behavior. Looking at the code these 64-bit masks are not used outside this package and they are only used with bitwise and operators. The change should not have any side effects. Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
A new Pull Request was created by @davidlt for CMSSW_7_2_X. Change Word64 type from long long to unsigned long long It involves the following packages: EventFilter/ESRawToDigi @cmsbuild, @nclopezo, @StoyanStoynev, @slava77 can you please review it and eventually sign? Thanks. |
This pull request is fully signed and it will be integrated in one of the next CMSSW_7_2_X IBs unless changes (tests are also fine). @nclopezo can you please take care of it? |
Change Word64 type from long long to unsigned long long
The following change is required to solve undefined behavior detected by
UBSan.
~Word64(0)
is-1
and left shifting a negative number is undefinedbehavior by C++.
These produce 3645 runtime errors from UBSan on full matrix. That's ~15%
of all detected runtime errors.
Word32
is defined as unsigned type. Keep it consistent and defineWord64
asunsigned long long
, thus resolved undefined behavior.Looking at the code these 64-bit masks are not used outside this package
and they are only used with bitwise and operators. The change should not
have any side effects.
Test case to prove that it does not affect the masks and solves the issue:
Signed-off-by: David Abdurachmanov David.Abdurachmanov@cern.ch