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

Fix reinterpret_cast to a wrong storage size #21170

Merged
merged 1 commit into from Nov 6, 2017

Conversation

davidlt
Copy link
Contributor

@davidlt davidlt commented Nov 5, 2017

This resolves #21096

ASan reported stack-buffer-overflow read of 8 bytes in
std::hash_specialization<float>::operator()(std::tuple<float> const&)

We have a float (4 bytes) and we get a reference to it as uint32_t (4
bytes), but later we get another reference as result_type
(std::size_t) which is 8 bytes. That's a different storage size. Thus
we will be reading extra 4 bytes from the memory, which don't belong to
the float.

Instead now we properly cast the resulting uint32_t to result_type,
which will not damange the number.

In workflow 4000.0 step3 this function is triggered 893'957 times each
time returning c61c3c00 (hex), i.e. the same value.

Before the fix numbers looked like:

 358'361 7ff5c61c3c00
 133'306 7fffc61c3c00
  65'670 c61c3c00
  38'466 c61c3c00c61c3c00
   6'039 3f1a36e2c61c3c00
   3'268 d5446cdcc61c3c00
     696 12c61c3c00
     306 3c21e3c5c61c3c00
     305 bc40413ec61c3c00
     305 4014b189c61c3c00
     303 40157dd9c61c3c00
     299 40140ebbc61c3c00
     293 4014df30c61c3c00
     293 401430f5c61c3c00
     288 40164789c61c3c00
    [..]

As you can see we almost always had extra garbage from the memory.
Only 65'670 out of 893'957 times function returned intended value.

Signed-off-by: David Abdurachmanov David.Abdurachmanov@cern.ch

This resolves cms-sw#21096

ASan reported stack-buffer-overflow read of 8 bytes in
`std::hash_specialization<float>::operator()(std::tuple<float> const&)`

We have a float (4 bytes) and we get a reference to it as `uint32_t` (4
bytes), but later we get another reference as `result_type`
(`std::size_t`) which is 8 bytes. That's a different storage size. Thus
we will be reading extra 4 bytes from the memory, which don't belong to
the float.

Instead now we properly cast the resulting `uint32_t` to `result_type`,
which will not damange the number.

In workflow 4000.0 step3 this function is triggered 893'957 times each
time returning `c61c3c00` (hex), i.e. the same value.

Before the fix numbers looked like:

     358'361 7ff5c61c3c00
     133'306 7fffc61c3c00
      65'670 c61c3c00
      38'466 c61c3c00c61c3c00
       6'039 3f1a36e2c61c3c00
       3'268 d5446cdcc61c3c00
         696 12c61c3c00
         306 3c21e3c5c61c3c00
         305 bc40413ec61c3c00
         305 4014b189c61c3c00
         303 40157dd9c61c3c00
         299 40140ebbc61c3c00
         293 4014df30c61c3c00
         293 401430f5c61c3c00
         288 40164789c61c3c00
        [..]

As you can see we almost always had extra garbage from the memory.
Only 65'670 out of 893'957 times function returned intended value.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 5, 2017

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 5, 2017

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/PR-21170/1828

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 5, 2017

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

It involves the following packages:

CondFormats/JetMETObjects

@ggovi, @cmsbuild, @monttj can you please review it and eventually sign? Thanks.
@TaiSakuma, @ahinzmann, @mmarionncern, @rappoccio, @jdamgov, @jdolen, @nhanvtran, @gkasieczka, @schoef, @mmusich, @mariadalfonso, @seemasharmafnal this is something you requested to watch as well.
@davidlange6, @slava77 you are the release manager for this.

cms-bot commands are listed here

@davidlange6
Copy link
Contributor

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 5, 2017

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/24188/console Started: 2017/11/05 13:34

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 5, 2017

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 5, 2017

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 5, 2017

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-21170/24188/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 26
  • DQMHistoTests: Total histograms compared: 2900266
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2900094
  • DQMHistoTests: Total skipped: 171
  • DQMHistoTests: Total Missing objects: 0
  • Checked 107 log files, 10 edm output root files, 26 DQM output files

@davidlange6
Copy link
Contributor

merge

@cmsbuild cmsbuild merged commit 9d3aefb into cms-sw:master Nov 6, 2017
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.

Invalid read of 8 bytes in JetCorrectorParametersHelper
3 participants