Project

General

Profile

Support #18849

add protection to art::Ptr

Added by Raymond Culbertson over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
01/30/2018
Due date:
% Done:

100%

Estimated time:
1.00 h
Spent time:
Scope:
Internal
Experiment:
Mu2e
SSI Package:
art
Duration:

Description

By creating a pathological product, I found this code

art::Ptr<SimParticle> const& pptr = obj.parent();
if(pptr) pkey = pptr->id().asUint();

can seg fault on the Ptr dereference. The expected behavior was that
if a Ptr passes the check in the if, then it will not seg fault on dereference.

In discussions with Kyle, it is possible to put in a check for this case, which is
basically a valid productID, but the key is out of bounds. I think clearly
if you ask for the dereference and it can't be dereferenced, that should throw
a severe error. But I'm not sure what is the best policy for the isAvailable
check, to return false or throw, so I leave that to the experts. I guess I would
vote for throw, since it would generally be a pathological situation to access
a Ptr with a valid productID but a key that is out of bounds.

History

#1 Updated by Christopher Green over 2 years ago

  • Status changed from New to Assigned
  • Assignee set to Kyle Knoepfel

#2 Updated by Kyle Knoepfel over 2 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Implemented with commit canvas:b1f7e47.

#3 Updated by Kyle Knoepfel over 2 years ago

  • Project changed from cet-is to canvas
  • Estimated time set to 1.00 h

#4 Updated by Kyle Knoepfel over 2 years ago

  • Target version set to 2.11.00

#5 Updated by Kyle Knoepfel over 2 years ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF