Support #2974
Problem with root persistence of an inherited struct
0%
Description
Dear root experts:
I have a problem using code which defines root schema using an inherited struct. My class structure is:
struct TrkHitInfo { .. data members }; struct DeltaHitInfo : TrkHitInfo { ... additional data members };
I use these in root schema using reflex:
(classes.h):
#include <vector> #include "TrkPatRec/inc/StrawHitInfo.hh" #include "TrkPatRec/inc/DeltaHitInfo.hh" template class std::vector<mu2e::StrawHitInfo>; template class std::vector<mu2e::DeltaHitInfo>;
(classes_def.xml):
<lcgdict> <class name="mu2e::StrawHitInfo" /> <class name="std::vector<mu2e::StrawHitInfo>" /> <class name="mu2e::DeltaHitInfo" /> <class name="std::vector<mu2e::DeltaHitInfo>" /> </lcgdict>
The schema and generated code compile fine, however there is a runtime error:
-bash-3.2$ mu2e -c debug.fcl %MSG-i MF_INIT_OK: mu2e 22-Sep-2012 07:38:06 PDT JobSetup Messagelogger initialization complete. %MSG terminate called after throwing an instance of 'cet::coded_exception<art::errors::ErrorCodes, &(art::ExceptionDetail::translate(art::errors::ErrorCodes))>' what(): ---- Configuration BEGIN Unable to load requested library /home/online1/brownd/mu2e/Mu2eSim/art2/Offline/lib/libTrkPatRec_dict.so /home/online1/brownd/mu2e/Mu2eSim/art2/Offline/lib/libTrkPatRec_dict.so: undefined symbol: vtable for mu2e::DeltaHitInfo ---- Configuration END
By contrast, persistent forms of StrawHitInfo work fine.
I have tried to force the creation of a virtual table in DeltaHitInfo
by declaring and implementing a virtual destructor, with no change in
the above. I'd be interested to know if root experts think this is an
art issue or a root issue.
thanks, David Brown
History
#1 Updated by Marc Paterno over 8 years ago
- Category set to User Code
- Status changed from New to Feedback
- Assignee set to Marc Paterno
So far, we have not yet been able to reproduce this problem. It may be that part of the implementation you have elided is the cause of our inability to reproduce it. All the data members and base members of the class for which the dictionary is being generated must have dictionaries.
However, the solution I would like to recommend first is to use containment, rather than public inheritance, for aggregation. This would avoid any need for virtual functions.
#2 Updated by Marc Mengel over 8 years ago
- Description updated (diff)
#3 Updated by Marc Mengel over 8 years ago
- Description updated (diff)
#4 Updated by Christopher Green over 7 years ago
- Tracker changed from Bug to Support
- Scope set to External
- Experiment Mu2e added
Could you tell us whether this is still an issue for you, and if not, how it was resolved?
#5 Updated by Christopher Green over 6 years ago
Is this still an issue or can it be resolved / closed ?
#6 Updated by David Brown over 6 years ago
- Status changed from Feedback to Closed
Since root persistence will change with root6 I don't think this question is directly relevant anymore, I'm happy to close it.