Skip to content
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

Merged

Conversation

smuzaffar
Copy link
Contributor

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

10001.0/step2:RecoLocalTracker/SiStripZeroSuppression/src/SiStripFedZeroSuppression.cc:95:22: runtime error: variable length array bound evaluates to non-positive value 0
10002.0/step2:RecoLocalTracker/SiStripZeroSuppression/src/SiStripFedZeroSuppression.cc:95:22: runtime error: variable length array bound evaluates to non-positive value 0
10003.0/step2:RecoLocalTracker/SiStripZeroSuppression/src/SiStripFedZeroSuppression.cc:95:22: runtime error: variable length array bound evaluates to non-positive value 0
10004.0/step2:RecoLocalTracker/SiStripZeroSuppression/src/SiStripFedZeroSuppression.cc:95:22: runtime error: variable length array bound evaluates to non-positive value 0

@cmsbuild
Copy link
Contributor

cmsbuild commented Jun 6, 2023

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-41881/35802

  • This PR adds an extra 16KB to repository

@cmsbuild
Copy link
Contributor

cmsbuild commented Jun 6, 2023

A new Pull Request was created by @smuzaffar (Malik Shahzad Muzaffar) for master.

It involves the following packages:

  • RecoLocalTracker/SiStripZeroSuppression (reconstruction)

@cmsbuild, @mandrenguyen, @clacaputo can you please review it and eventually sign? Thanks.
@echabert, @VourMa, @gbenelli, @missirol, @GiacomoSguazzoni, @yduhm, @robervalwalsh, @JanFSchulte, @rovere, @VinInn, @alesaggio, @felicepantaleo, @mtosi, @gpetruc, @mmusich, @threus, @jlidrych this is something you requested to watch as well.
@perrotta, @dpiparo, @rappoccio you are the release manager for this.

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
      |                  ~~~~~~^~~~

@smuzaffar
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jun 6, 2023

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-240b3e/33010/summary.html
COMMIT: 5be700a
CMSSW: CMSSW_13_2_X_2023-06-06-1100/el8_amd64_gcc11
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/41881/33010/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially added 18 lines to the logs
  • Reco comparison results: 5 differences found in the comparisons
  • DQMHistoTests: Total files compared: 48
  • DQMHistoTests: Total histograms compared: 3219909
  • DQMHistoTests: Total failures: 6
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3219881
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 47 files compared)
  • Checked 207 log files, 159 edm output root files, 48 DQM output files
  • TriggerResults: no differences found

@mandrenguyen
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

cmsbuild commented Jun 7, 2023

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)

@perrotta
Copy link
Contributor

perrotta commented Jun 7, 2023

+1

@cmsbuild cmsbuild merged commit d600d75 into cms-sw:master Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants