Fix null-pointer dereference in CAFMaker truth matching + leak and copies#304
Draft
gavinsdavies wants to merge 1 commit into
Draft
Fix null-pointer dereference in CAFMaker truth matching + leak and copies#304gavinsdavies wants to merge 1 commit into
gavinsdavies wants to merge 1 commit into
Conversation
…e buffer leak, and per-event product vector copies
4 tasks
Collaborator
|
✔️ CI build for EMPHATIC Succeeded on slf7 for maxopt -- details available through the CI dashboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #303.
Fixes
Null-pointer dereference in truth matching (
VertexFiller.cxx, two occurrences). The truth-match fallback triesid,id+1,id-1inssdHitMap; when all three lookups fail it setsisOk = false, but the next line unconditionally evaluatedabs(ssdHitMap[id]->PId()). On a missing key,std::map::operator[]inserts a nullsim::SSDHit*which is immediately dereferenced — UB/crash whenever a track line segment has no nearby truth hit. Fixed with a short-circuit guard (isOk && ...); the id-fallback semantics are unchanged (when a lookup succeeds,idis left at the found key exactly as before).File-name buffer leak (
CAFMaker_module.cc::respondToOpenInputFile).new char[]+strcpy+basename(), never freed. Replaced withstd::string-only basename logic; no raw buffer.Per-event product vector copies (
VertexFiller.cxx,ClusterFiller.cxx). Full copies of the vertex/SSD-hit/cluster product vectors per event replaced with const references (empty-vector fallback preserved).trksandarichidsare deliberately left as copies:GetBeamTrack/GetSecondaryTracktake non-constrb::Track&/rb::ArichID&, so const-ref elements cannot bind — noted in a comment; changing those signatures is out of scope here.Verification
Behavior-preserving by construction except the dereference guard, whose before/after is described above (before: UB; after: the electron check is skipped only when no hit was found, in which case
isOkalready excluded the truth record). Downstream read-only use of the converted containers was checked. No local art/UPS build environment and no repo CI — a collaborator build before undrafting would be appreciated.🤖 Assisted by Claude Code (claude-fable-5)