Hi all,
I have a segfault when ending an application that is reading a file that contains a custom class (MUH1D - a new subclass of H1D). The (core parts) of the code worked a year or two ago, but now I am trying to get it working with a different environment and build set up and I think I am missing something in the dictionary generation or something similar.
The backtrace looks like this:
(lldb) bt
- thread #1: tid = 0x46e97, 0x000000010096485d libCore.so`TList::FindObject(TObject const*) const + 45, queue = ‘com.apple.main-thread’, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
- frame #0: 0x000000010096485d libCore.so
TList::FindObject(TObject const*) const + 45 frame #1: 0x000000010096434f libCore.so
TList::Clear(char const*) + 143
frame #2: 0x0000000100962c63 libCore.soTHashTable::Clear(char const*) + 83 frame #3: 0x00000001009622a9 libCore.so
THashList::Delete(char const*) + 57
frame #4: 0x000000010098d16b libCore.soTClass::SetUnloaded() + 171 frame #5: 0x000000010095c66f libCore.so
ROOT::RemoveClass(char const*) + 95
frame #6: 0x0000000100995924 libCore.soROOT::TGenericClassInfo::~TGenericClassInfo() + 148 frame #7: 0x00007fff8ced9521 libsystem_c.dylib
__cxa_finalize + 200
frame #8: 0x00007fff8cedb68b libsystem_c.dylib`exit + 15
- frame #0: 0x000000010096485d libCore.so
This is with ROOT v5-34-18. The code looks like so (it was originally much longer, but has been chopped down):
int main() {
ROOT::Cintex::Cintex::Enable();
return tryToRead();
}
int tryToRead() {
TFile f(“wroteSomething.root”);
f.Close();
return 0;
}
The code that writes the files appears to work fine (the custom class histograms make nice plots, etc.). Chopped down it looks like so:
int main() {
MUH1D* a = new MUH1D(“a”,“going to disk”, 10, 0., 10. );
TFile f(“wroteSomething.root”,“recreate”);
a->Write(“MyHist”); //the name in the file is MyHist
f.Close();
return 0;
}
Of course, the class definition is long, but the most relevant file is probably the Linkdef.h, which looks like this:
#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;
#pragma link C++ namespace PlotUtils;
#pragma link C++ class PlotUtils::MULatErrorBand+;
#pragma link C++ class PlotUtils::MUVertErrorBand+;
#pragma link C++ class PlotUtils::MUH1D+;
#endif
Additionally, in the Makefile I produce a dictionary via (again, edited down a bit for brevity):
ROOTDICTCXX = MUHDict.cxx
ROOTDICTH = MUHDict.h
ROOTDICTHEADERS = MULatErrorBand.h MUVertErrorBand.h MUH1D.h MUApplication.h
$(TARGET): $(OBJS) $(ROOTDICTCXX)
$(CXX) $(LDFLAGS) -o $(TARGET) $(OBJS) $(ROOTFLAGS)
mv $(TARGET) …/lib
$(OBJS): %.o: %.cxx %.h
$(CXX) $(CXXFLAGS) $(INCLUDE) $(ROOTINC) -c $< -o $@
$(ROOTDICTCXX): $(ROOTDICTHEADERS) Linkdef.h
rootcint -f $@ -c $(CXXFLAGS) -p $^
I’ve Googled around a bit using snippets from the backtrace but I don’t see anything promising. Any ideas?