Class member causes seg fault when GetEntry()

I have a tree full of a class that I wrote called Event. When I try to GetEntry() on the tree, I get a seg fault. One of the members is another class called StPythiaEvent. When I remove this member from my class, the error no longer occurs. Incidentally, when I had a different class fulfilling the same function as StPythiaEvent, the same error occurred. When the member is present, but not used, the error still occurs.

Any tips or ideas about solving this problem would be appreciated.


Below is the output when running root in gdb. test.C loads some libraries. Everything was compiled in root 5.12 and gcc 3.46.

root4star [0] .x test.C
root4star [1] fEvent = new Event;
root4star [2] fChain = new TChain("jpsiTree");
root4star [3] fChain->Add("jpsi200test.tree.root");
root4star [4] fChain->SetBranchAddress("eventBranch",&fEvent);
root4star [5] fChain->GetEntry(0)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208039744 (LWP 24723)]
0x03d3820e in ROOT::delete_StPythiaEvent ()
   from /star/u/mattheww/.sl44_gcc346/lib/
(gdb) bt
#0  0x03d3820e in ROOT::delete_StPythiaEvent ()
   from /star/u/mattheww/.sl44_gcc346/lib/
#1  0x005ebba5 in TClass::Destructor (this=0xc4f4ad0, obj=0x2f726174, 
    dtorOnly=false) at meta/src/TClass.cxx:2917
#2  0x004ed821 in TBuffer::ReadFastArray (this=0xc5d3900, start=0xc36d3e4, 
    cl=0xc4f4ad0, n=1, isPreAlloc=false, streamer=0x0)
    at base/src/TBuffer.cxx:1594
#3  0x0061b2dd in TStreamerInfo::ReadBuffer<char**> (this=0xc454b60, 
    b=@0xc5d3900, arr=@0xbff801bc, first=6, narr=1, eoffset=0, arrayMode=0)
    at meta/src/TStreamerInfoReadBuffer.cxx:836
#4  0x01357b93 in TBranchElement::ReadLeaves (this=0xc5d24c8, b=@0xc5d3900)
    at tree/src/TBranchElement.cxx:1973
#5  0x01347c64 in TBranch::GetEntry (this=0xc5d24c8, entry=0, getall=0)
    at tree/src/TBranch.cxx:983
#6  0x01354eae in TBranchElement::GetEntry (this=0xc5d24c8, entry=0, getall=0)
    at tree/src/TBranchElement.cxx:1308
#7  0x01354e17 in TBranchElement::GetEntry (this=0xc562950, entry=0, getall=0)
    at tree/src/TBranchElement.cxx:1298
#8  0x01398b4f in TTree::GetEntry (this=0xc4269b8, entry=0, getall=0)
    at tree/src/TTree.cxx:3242
#9  0x013650eb in TChain::GetEntry (this=0xc377b78, entry=0, getall=0)
    at tree/src/TChain.cxx:697
#10 0x013f6641 in G__G__Tree_229_8_2 ()
   from /afs/
#11 0x00f9cff9 in G__ExceptionWrapper (
    funcp=0x13f652e <G__G__Tree_229_8_2(G__value*, char const*, G__param*, int)>, result7=0xbffde760, funcname=0xc397830 "\n", libp=0xbffb4220, hash=8)
    at cint/src/Api.cxx:372
#12 0x0105f198 in G__call_cppfunc (result7=0xbffde760, libp=0xbffb4220, 
    ifunc=0xc397830, ifn=8) at cint/src/v6_newlink.cxx:466
#13 0x01049576 in G__interpret_func (result7=0xbffde760, 
    funcname=0xbffdd760 "GetEntry", libp=0xbffb4220, hash=818, 
    p_ifunc=0xc397830, funcmatch=1, memfunc_flag=1)
    at cint/src/v6_ifunc.cxx:5172
#14 0x01031c32 in G__getfunction (item=0xbffdfe38 "GetEntry(0)", 
    known3=0xbffed0fc, memfunc_flag=1) at cint/src/v6_func.cxx:2604
#15 0x010e2ec8 in G__getstructmem (store_var_type=112, varname=0xbffeaf90 "A", 
    membername=0xbffdfe38 "GetEntry(0)", tagname=0xbffdfe30 "fChain", 
    known2=0xbffed0fc, varglobal=0x1173600, objptr=2)
    at cint/src/v6_var.cxx:4473
#16 0x010d8564 in G__getvariable (item=0xbffedb90 "fChain->GetEntry(0)", 
    known2=0xbffed0fc, varglobal=0x1173600, varlocal=0x0)
    at cint/src/v6_var.cxx:3239
#17 0x0102615e in G__getitem (item=0xbffedb90 "fChain->GetEntry(0)")
    at cint/src/v6_expr.cxx:1851
#18 0x01024830 in G__getexpr (expression=0xbffefe70 "fChain->GetEntry(0)")
#19 0x0107d4d0 in G__exec_function (
    statement=0xbffefe70 "fChain->GetEntry(0)", pc=0xbffefe6c, 
    piout=0xbffefe60, plargestep=0xbffefe50, presult=0xbfff0e70)
    at cint/src/v6_parse.cxx:462
#20 0x01086b4b in G__exec_statement () at cint/src/v6_parse.cxx:4190
#21 0x0100501d in G__exec_tempfile_core (file=0x0, fp=0xc388f18)
    at cint/src/v6_debug.cxx:363
#22 0x0100527a in G__exec_tempfile_fp (fp=0xc388f18)
    at cint/src/v6_debug.cxx:430
#23 0x010916b0 in G__process_cmd (line=0xc388e58 "fChain->GetEntry(0)", 
    prompt=0x9f097ec "", more=0x9f097e4, err=0xbfffdeac, rslt=0xbfffdeb0)
    at cint/src/v6_pause.cxx:3357
#24 0x005d941e in TCint::ProcessLine (this=0x9f097c8, 
    line=0xc388e58 "fChain->GetEntry(0)", error=0x0) at meta/src/TCint.cxx:321
#25 0x004dc784 in TApplication::ProcessLine (this=0x9ffde70, 
    line=0xc388e58 "fChain->GetEntry(0)", sync=false, err=0x0)
    at base/src/TApplication.cxx:738
#26 0x0036c5a2 in TRint::HandleTermInput (this=0x9ffde70)
    at rint/src/TRint.cxx:475
#27 0x0036a904 in TTermInputHandler::Notify (this=0xa366d10)
    at rint/src/TRint.cxx:125
#28 0x0036d08c in TTermInputHandler::ReadNotify (this=0xa366d10)
    at rint/src/TRint.cxx:117
#29 0x00681bb4 in TUnixSystem::CheckDescriptors (this=0x9f07290)
    at unix/src/TUnixSystem.cxx:1036
#30 0x00680ef2 in TUnixSystem::DispatchOneEvent (this=0x9f07290, 
    pendingOnly=false) at unix/src/TUnixSystem.cxx:749
#31 0x0057c9ea in TSystem::InnerLoop (this=0x9f07290)
    at base/src/TSystem.cxx:416
#32 0x0057c97a in TSystem::Run (this=0x9f07290) at base/src/TSystem.cxx:384
#33 0x004dd164 in TApplication::Run (this=0x9ffde70, retrn=false)
    at base/src/TApplication.cxx:867
#34 0x0036bdb8 in TRint::Run (this=0x9ffde70, retrn=false)
    at rint/src/TRint.cxx:334
#35 0x080b8c54 in main (argc=1, argv=0xbfffe604)
    at .sl44_gcc346/obj/asps/rexe/MAIN_rmain.cxx:32

It looks like you do not initialize the pointer to your StPythiaEvent object.
I suggest running your code under valgrind.


Ah, thank you for your help.