SegFault on GetEntry

Hi experts,

I am trying to run a “flattener” over a TTree I have made using my own event loop, but when I run tchain->GetEntry(X) I get a segfault. I have been smashing my head against this for way to long and can’t figure out what exactly is going wrong. I hope someone can help expand my knowledge.

Steps to recreate this bug.

Run Interacitvely

.L ShortTreeReader.C

I may as well include ShortTreeReader.C here, as it is simple enough.

` 1 #include "EventRecord.h" `
  3 #ifndef CalibTreeReader_H  
  4 #define CalibTreeReader_H  
  6 void TreeReader(){  
  7   //TFile* f = new TFile("CalibTree_RSources_wbkg_test.root");  
  8   string outname = "test";  
  9   TChain* ch = new TChain("calibTree/CalibrationRecordTree");  
 10   ch->Add("CalibTree_RSources_wbkg_test.root");  
 11   EventRecord::EventRecord* event;  
 12   ch->SetBranchAddress("event_records", &event);  
 13   std::cout<<"43\n";  
 15   Int_t mevt = ch->GetEntries();  
 17   for(int nevt=0; nevt<mevt; ++nevt){  
 18     ch->GetEntry(nevt);  
 19     std::cout<<"Successs. The Run Number is   :"<<event->run<<"\n";  
 20   }  
 23 }  
 25 #endif  

I have a single event available for use in testing, the event class, and the tree reader at

I have confirmed that it is in GetEntry that the segfault happens, but I am inexperienced with using gdb on interpreted root macros and have been unable to progress further.

The stack trace from the crash is

Cheers, and thanks in advance for any help offered.

ROOT Version (e.g. 6.12/02):
Fedora 27, gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)

 11   EventRecord::EventRecord *event = 0;

 21   delete ch;
 22   delete event; // cleanup

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.