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][Math] Suppress signed-integer-overflow for approx_exp #46417

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

smuzaffar
Copy link
Contributor

This PR suggests to suppress [a] UBSAN runtime errors. According to #11753 (comment) this overflow should be considered as feature. This change will suppress the signed-integer-overflow runtime error coming from unsafe_expf_impl() function.

Note that CMS_UNDEFINED_SANITIZER is cpp macro which is only set when we build UBSAN IBs.

FYI @VinInn, let me know if you have any better way to fix/suppress this error

Fixes #46396

[a]

136.821/step3:DataFormats/Math/interface/approx_exp.h:154:5: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
136.821/step3:DataFormats/Math/interface/approx_exp.h:162:32: runtime error: signed integer overflow: 2147483647 + 127 cannot be represented in type 'int'

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 17, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46417/42271

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@cmsbuild
Copy link
Contributor

@smuzaffar
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @smuzaffar for master.

It involves the following packages:

  • DataFormats/Math (reconstruction)

@jfernan2, @mandrenguyen can you please review it and eventually sign? Thanks.
@fabiocos, @felicepantaleo, @makortel, @missirol, @mmusich, @rovere this is something you requested to watch as well.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.

cms-bot commands are listed here

@VinInn
Copy link
Contributor

VinInn commented Oct 17, 2024

just tell USBAN to not worry: we know better

@smuzaffar
Copy link
Contributor Author

just tell USBAN to not worry: we know better

thanks @VinInn . I think this is what this PR is proposing (ignore the signed integer overflow for unsafe_expf_impl() function for UBSAN build)

@smuzaffar
Copy link
Contributor Author

I will do the same for UBSAN vdt runtime error

vdt/sincos.h:214:6: runtime error: signed integer overflow: -2147483648 - 2 cannot be represented in type 'int'

@VinInn
Copy link
Contributor

VinInn commented Oct 17, 2024

said that: in principle
x = std::min(std::max(x, zero_threshold_ftz), inf_threshold);
should avoid the overflow....

@smuzaffar
Copy link
Contributor Author

Or we change https://github.com/cms-sw/cmssw/blob/master/DataFormats/Math/interface/approx_exp.h#L168

-#ifndef NO_APPROX_MATH
+#if !defined(NO_APPROX_MATH) && !defined(CMS_UNDEFINED_SANITIZER)

so that for ubsan we use std::exp(x);

@smuzaffar
Copy link
Contributor Author

ah forget my #46417 (comment) , that will not work. UBSAN will still see the unsafe_expf_impl

@smuzaffar
Copy link
Contributor Author

test parameters:

  • workflow = 136.821

@smuzaffar
Copy link
Contributor Author

please test for CMSSW_14_2_UBSAN_X

@cmsbuild
Copy link
Contributor

+1

Size: This PR adds an extra 20KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-1e4dee/42254/summary.html
COMMIT: d85088f
CMSSW: CMSSW_14_2_X_2024-10-16-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/46417/42254/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 44
  • DQMHistoTests: Total histograms compared: 3335129
  • DQMHistoTests: Total failures: 455
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3334654
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 43 files compared)
  • Checked 193 log files, 163 edm output root files, 44 DQM output files
  • TriggerResults: no differences found

@@ -122,7 +122,11 @@ end;

// valid for -87.3365 < x < 88.7228
template <int DEGREE>
constexpr float unsafe_expf_impl(float x) {
#ifdef CMS_UNDEFINED_SANITIZER
__attribute__((no_sanitize("signed-integer-overflow")))
Copy link
Contributor

@makortel makortel Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add comments explaining why this is done? (so that a curious reader would not have to do GitHub archaeology)

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Pull request #46417 was updated. @cmsbuild, @jfernan2, @mandrenguyen can you please check and sign again.

@smuzaffar
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

+1

Size: This PR adds an extra 24KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-1e4dee/42283/summary.html
COMMIT: d510b7b
CMSSW: CMSSW_14_2_X_2024-10-17-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/46417/42283/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially added 2 lines to the logs
  • Reco comparison results: 2 differences found in the comparisons
  • DQMHistoTests: Total files compared: 47
  • DQMHistoTests: Total histograms compared: 3604451
  • DQMHistoTests: Total failures: 415
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3604016
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 46 files compared)
  • Checked 205 log files, 174 edm output root files, 47 DQM output files
  • TriggerResults: no differences found

@jfernan2
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

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. @antoniovilela, @sextonkennedy, @mandrenguyen, @rappoccio (and backports should be raised in the release meeting by the corresponding L2)

@mandrenguyen
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit cbb7c89 into cms-sw:master Oct 18, 2024
12 checks passed
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.

[UBSAN] Runtime errors from approx_exp.h
6 participants