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 undefined behavior in MuonIdProducer from empty pointer #35303

Merged
merged 2 commits into from
Sep 16, 2021

Conversation

trocino
Copy link
Contributor

@trocino trocino commented Sep 16, 2021

PR description:

Fix undefined behavior in MuonIdProducer, reported in issue 35036. This is caused by the theShowerDigiFiller_ pointer, which is used empty to call function fillDefault(...) whenever the fillShowerDigis_ flag is false, e.g. in HLT.

I added a default constructor without parameters for MuonShowerDigiFiller, which is only used when fillShowerDigis_ is false. Function fillDefault(...) doesn't use any data member of MuonShowerDigiFiller and can be called even with this minimal initialization.
In one point I also had to fix the condition to use the fully initialized MuonShowerDigiFiller.

PR validation:

The code compiles without errors and passes the basic tests in CMSSW_12_1_X_2021-09-15-1100. I verified that the undefined behavior error disappears, running wf 11603.0 in CMSSW_12_1_UBSAN_X_2021-09-13-1100.

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35303/25314

  • This PR adds an extra 24KB to repository

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

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35303/25319

  • This PR adds an extra 24KB to repository

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @trocino (Daniele Trocino) for master.

It involves the following packages:

  • RecoMuon/MuonIdentification (reconstruction)

@jpata, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks.
@HuguesBrun, @calderona, @abbiendi, @jhgoh, @bellan, @sscruz, @Fedespring, @cericeci, @rociovilar this is something you requested to watch as well.
@perrotta, @dpiparo, @qliphy you are the release manager for this.

cms-bot commands are listed here

@@ -46,6 +46,7 @@

class MuonShowerDigiFiller {
public:
MuonShowerDigiFiller() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

is this really needed with an empty body? it should already be the same as the implicit default.
please drop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there an implicit default constructor? If I remove this line, I get a compilation error at the instantiation without parameters here. From the error message, it looks like there is an implicit copy constructor instead:

/.../unique_ptr.h: In instantiation of 'typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = MuonShowerDigiFiller; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<MuonShowerDigiFiller>]':

/.../plugins/MuonIdProducer.cc:93:67: required from here
/.../unique_ptr.h:962:30: error: no matching function for call to 'MuonShowerDigiFiller::MuonShowerDigiFiller()'
962 | { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }

In file included from /.../plugins/MuonIdProducer.h:49,
from /.../plugins/MuonIdProducer.cc:12:
/.../interface/MuonShowerDigiFiller.h:49:3: note: candidate: 'MuonShowerDigiFiller::MuonShowerDigiFiller(const edm::ParameterSet&, edm::ConsumesCollector&&)'
49 | MuonShowerDigiFiller(const edm::ParameterSet&, edm::ConsumesCollector&& iC);
/.../interface/MuonShowerDigiFiller.h:49:3: note: candidate expects 2 arguments, 0 provided

/.../interface/MuonShowerDigiFiller.h:47:7: note: candidate: 'MuonShowerDigiFiller::MuonShowerDigiFiller(const MuonShowerDigiFiller&)'
47 | class MuonShowerDigiFiller {
/.../interface/MuonShowerDigiFiller.h:47:7: note: candidate expects 1 argument, 0 provided

/.../interface/MuonShowerDigiFiller.h:47:7: note: candidate: 'MuonShowerDigiFiller::MuonShowerDigiFiller(MuonShowerDigiFiller&&)'
/.../interface/MuonShowerDigiFiller.h:47:7: note: candidate expects 1 argument, 0 provided

@@ -46,6 +46,7 @@

class MuonShowerDigiFiller {
public:
MuonShowerDigiFiller() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for checking.
I forgot that the implicit default is created only if there is no other kind defined.

@slava77
Copy link
Contributor

slava77 commented Sep 16, 2021

@cmsbuild please test

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-f57395/18667/summary.html
COMMIT: 2577c56
CMSSW: CMSSW_12_1_X_2021-09-16-1100/slc7_amd64_gcc900
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/35303/18667/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: 3 differences found in the comparisons
  • DQMHistoTests: Total files compared: 39
  • DQMHistoTests: Total histograms compared: 3000833
  • DQMHistoTests: Total failures: 5
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 3000805
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.004 KiB( 38 files compared)
  • DQMHistoSizes: changed ( 312.0 ): 0.004 KiB MessageLogger/Warnings
  • Checked 165 log files, 37 edm output root files, 39 DQM output files
  • TriggerResults: no differences found

@slava77
Copy link
Contributor

slava77 commented Sep 16, 2021

+reconstruction

for #35303 2577c56

  • code changes are in line with the PR description and should address the UBSAN issue based on just the visual inspection (even though it's not obvious why the code calling fillDefault was not crashing already )
  • jenkins tests pass and comparisons with the baseline show no (relevant) differences

@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. @perrotta, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2)

@perrotta
Copy link
Contributor

+1

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.

4 participants