MuidCalo - Fix crashes related to ownership handling of Surfaces
Hi everybody,
this is hopefully the last MR to fix the issues reported in ATLASRECTS-6381. It took me quite some time to chase the underlying issues. They are a somehow interesting handling of the surface pointers associated to the TrackParameters. I was assuming that their pointer is an observer pointer of the surface retrieved from the TrackingGeometry. God, I was so wrong as the Parameters clone their surface (cf. here). After having this settled out the code further crashed as the MaterialEffectsBase
still hold an observer pointer cf. here. Given, that the TrackParameters used in their ctor
have been trashed in the meantime, you can straightforward imagine that the code will crash here as well. I think this is a good example to advertise again that std::shared_ptr<const T>
might be useful in cases where information is just copied from one object to another and not touched at all. It ensures memory safety, as the last descoper also switches off the light, and more importantly, the object pointer is always valid without copying the same information over and over through the pipe. What, I do not know how this scales with threading efficiency, etc. Anyway, let me mention @christos, @sroe as they might want to change the observer pointer in MaterialEffectsBase
to a smart pointer. I've seen in quite a few places that the code generates MaterialEffects in the manner described above, but I just imagine that these branches are never executed.
Adding: @goblirsc to solve another philosopher of the day - The unsolved ones are stacking up Max!