-
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
Fix undefined behavior in MuonIdProducer from empty pointer #35303
Fix undefined behavior in MuonIdProducer from empty pointer #35303
Conversation
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35303/25314
Code check has found code style and quality issues which could be resolved by applying following patch(s)
|
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35303/25319
|
A new Pull Request was created by @trocino (Daniele Trocino) for master. It involves the following packages:
@jpata, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@@ -46,6 +46,7 @@ | |||
|
|||
class MuonShowerDigiFiller { | |||
public: | |||
MuonShowerDigiFiller() {} |
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.
is this really needed with an empty body? it should already be the same as the implicit default.
please drop.
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.
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() {} |
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.
thanks for checking.
I forgot that the implicit default is created only if there is no other kind defined.
@cmsbuild please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-f57395/18667/summary.html Comparison SummarySummary:
|
+reconstruction
|
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) |
+1 |
PR description:
Fix undefined behavior in
MuonIdProducer
, reported in issue 35036. This is caused by thetheShowerDigiFiller_
pointer, which is used empty to call functionfillDefault(...)
whenever thefillShowerDigis_
flag is false, e.g. in HLT.I added a default constructor without parameters for
MuonShowerDigiFiller
, which is only used whenfillShowerDigis_
is false. FunctionfillDefault(...)
doesn't use any data member ofMuonShowerDigiFiller
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 inCMSSW_12_1_UBSAN_X_2021-09-13-1100
.