-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[UBSAN] Fix runtime error about variable length array bound #41881
[UBSAN] Fix runtime error about variable length array bound #41881
Conversation
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-41881/35802
|
A new Pull Request was created by @smuzaffar (Malik Shahzad Muzaffar) for master. It involves the following packages:
@cmsbuild, @mandrenguyen, @clacaputo can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@@ -83,17 +83,21 @@ void SiStripFedZeroSuppression::suppress(const std::vector<SiStripDigi>& in, | |||
uint32_t detID, | |||
const SiStripNoises& noise, | |||
const SiStripThreshold& threshold) { | |||
int inSize = in.size(); | |||
selectedSignal.clear(); | |||
size_t inSize = in.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.
why changing it to size_t
?
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.
It was not needed to fix the UBSAN error but thought that as inSize
is >=0 ( std::vector::size()
returns size_t
... rigth) that is why I converted it to size_t
and then update loop index i
to be of same type and avoid extra arithmetic [a]
[a]
RecoLocalTracker/SiStripZeroSuppression/src/SiStripFedZeroSuppression.cc:144:22: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
144 | } else if (i - 1 >= 0 && in[i - 1].strip() == strip - 1) {
| ~~~~~~^~~~
RecoLocalTracker/SiStripZeroSuppression/src/SiStripFedZeroSuppression.cc:148:24: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
148 | } else if (i - 2 >= 0 && in[i - 2].strip() == strip - 2) {
| ~~~~~~^~~~
please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-240b3e/33010/summary.html Comparison SummarySummary:
|
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @rappoccio (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
This should fix the ubsan errors of type [a].
SiStripFedZeroSuppression::suppress(...)
does not do much for inSize=0.[a] https://cmssdt.cern.ch/SDT/jenkins-artifacts/ubsan_logs/CMSSW_13_2_X_2023-06-02-2300/logs/50/5072528821a0b4b2f766743a9c79dd0d/log