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
Avoid deref of Ref in copy constructor of PackedCandidate #32964
Conversation
Previously if the vertex had not been read from the original, a call to a copy constructor would cause the deref to happen.
Please test |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-32964/21199
|
A new Pull Request was created by @Dr15Jones (Chris Jones) for master. It involves the following packages: DataFormats/PatCandidates @perrotta, @jpata, @slava77 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-10b87b/13016/summary.html Comparison SummarySummary:
|
is there a chance that a |
dxy_(vertex_ ? iOther.dxy_ : 0), | ||
dz_(vertex_ ? iOther.dz_ : 0), | ||
dphi_(vertex_ ? iOther.dphi_ : 0), | ||
deta_(vertex_ ? iOther.deta_ : 0), | ||
dtrkpt_(vertex_ ? iOther.dtrkpt_ : 0), |
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.
this doesn't look right; having a null vertex does not imply zero values in these parameters
cmssw/DataFormats/PatCandidates/src/PackedCandidate.cc
Lines 122 to 132 in 22f5521
void pat::PackedCandidate::unpackVtx() const { | |
reco::VertexRef pvRef = vertexRef(); | |
dphi_ = int16_t(packedDPhi_) * 3.2f / std::numeric_limits<int16_t>::max(), | |
deta_ = MiniFloatConverter::float16to32(packedDEta_); | |
dtrkpt_ = MiniFloatConverter::float16to32(packedDTrkPt_); | |
dxy_ = MiniFloatConverter::float16to32(packedDxy_) / 100.; | |
dz_ = pvRef.isNonnull() ? MiniFloatConverter::float16to32(packedDz_) / 100. | |
: int16_t(packedDz_) * 40.f / std::numeric_limits<int16_t>::max(); | |
Point pv = pvRef.isNonnull() ? pvRef->position() : Point(); | |
float phi = p4_.load()->Phi() + dphi_, s = std::sin(phi), c = std::cos(phi); | |
auto vertex = std::make_unique<Point>(pv.X() - dxy_ * s, |
I think that the unpacking of parameters not dependent on the value of the
vertexRef
should still happen.
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.
uhm, on a second thought, perhaps not and the changes are OK, but that becomes a bit more obvious only after seeing that all cases to access the dxy_
through dtrkpt_
values rely on having unpackVtx
called.
I see a path after this PR change that a candidate that comes out of this PackedCandidate(const PackedCandidate &iOther)
with iOther.vertex_ == nullptr
can get to e.g. a call to ::packVtx
without a preceding unpackVtx
(e.g. via ::setTrackProperties
) and lead to a crash in
cmssw/DataFormats/PatCandidates/src/PackedCandidate.cc
Lines 26 to 29 in 22f5521
void pat::PackedCandidate::packVtx(bool unpackAfterwards) { | |
reco::VertexRef pvRef = vertexRef(); | |
Point pv = pvRef.isNonnull() ? pvRef->position() : Point(); | |
float dxPV = vertex_.load()->X() - pv.X(), |
This looks like a maybeUnpackBoth()
call is needed in ::setTrackProperties
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.
Good catch! I made the change.
Those methods either already avoid reading the |
This protects the call to pack() which requires the variables have already been unpacked.
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-32964/21238
|
please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-10b87b/13064/summary.html Comparison SummarySummary:
|
+1
As I recall in the past similar symptoms were an indication of some issues in the Frontier infrastructure |
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. @silviodonato, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
Previously if the vertex had not been read from the original, a call to a copy constructor would cause the deref to happen.
The copy constructor was being called by ROOT during read back from a file. This meant while we were reading the branch holding the PackedCandidate we were trigger reading the branch holding the Vertexes.
PR validation:
The code compiles and the extended unit test passes.