Can not access TTree filled with TNamed inherited objects

Hi ROOTers,

I have the following issue. I would like to fill a TTree with objects inheriting from TNamed so that I can also fill them in a TList, if required. When I let the object inherit from TNamed, fill the tree and try to access the entries by TTree::Scan or in the Browser I get seg faults (see footer).
As soon as I remove the dependency to TNamed everything seems fine. Any idea what I would have to modify in order to get it working with TNamed inheritance as well? Thanks!

best,
Daniel

after calling TTree::Scan I get


  • Row * mean * MvtCubeSt *

*** Break *** segmentation violation

===========================================================
There was a crash (kSigSegmentationViolation).
This is the entire stack trace of all threads:

#0 0xb77c9424 in __kernel_vsyscall ()
#1 0xb642f833 in __waitpid_nocancel () from /lib/i686/cmov/libc.so.6
#2 0xb63cd46b in do_system () from /lib/i686/cmov/libc.so.6
#3 0xb64fd4ad in system () from /lib/i686/cmov/libpthread.so.0
#4 0xb7231bb5 in TUnixSystem::Exec (this=0x891af38,
shellcmd=0x912c778 “/usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/etc/gdb-backtrace.sh 8840 1>&2”)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/unix/src/TUnixSystem.cxx:2031
#5 0xb7230d95 in TUnixSystem::StackTrace (this=0x891af38)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/unix/src/TUnixSystem.cxx:2253
#6 0xb7234390 in TUnixSystem::DispatchSignals (this=0x891af38,
sig=kSigSegmentationViolation)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/unix/src/TUnixSystem.cxx:1157
#7 0xb72344c6 in SigHandler (sig=kSigSegmentationViolation)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/unix/src/TUnixSystem.cxx:357
#8 0xb72295bd in sighandler (sig=11)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/unix/src/TUnixSystem.cxx:3522
#9
#10 0xb5999f4d in MvtCubeStats::Streamer ()
from /u/drichter/share/lib/libMvtCommon.so
#11 0xb7140f02 in TObject::SavePrimitive (this=0x914f018, out=
0x1)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/base/src/TObject.cxx:673
#12 0xb56fe042 in TBufferFile::MapObject (this=0x912be20, obj=0x914f018,
offset=1)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/io/io/src/TBufferFile.cxx:3058
#13 0xb4ab7206 in TBranchElement::ReadLeavesMember (this=0x909bff8,
b=
0x912be20)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/tree/src/TBranchElement.cxx:3511
#14 0xb4aae008 in TBranch::GetEntry (this=0x909bff8, entry=0, getall=0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/tree/src/TBranch.cxx:1245
#15 0xb4ab82e1 in TBranchElement::GetEntry (this=0x909bff8, entry=0, getall=0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/tree/src/TBranchElement.cxx:1949
#16 0xb2f97203 in R__LoadBranch (br=0x909bff8, entry=0, quickLoad=false)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/treeplayer/src/TTreeFormula.cxx:99
#17 0xb2f9d87a in TTreeFormula::EvalInstance (this=0x911e628, instance=0,
stringStackArg=0x0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/treeplayer/src/TTreeFormula.cxx:3845
#18 0xb2f9d4fc in TTreeFormula::PrintValue (this=0x911e628, mode=0,
instance=0, decform=0x8d32e48 “9.9”)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/treeplayer/src/TTreeFormula.cxx:4757
#19 0xb2fc1abd in TTreePlayer::Scan (this=0x8c9b3b8, varexp=0xb4c0ff3c “”,
selection=0xb4c0ff3c “”, option=0xb4c0ff3c “”, nentries=1, firstentry=0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/treeplayer/src/TTreePlayer.cxx:3231
#20 0xb4b19b12 in TTree::Scan (this=0x8a1fc18, varexp=0xb4c0ff3c “”,
selection=0xb4c0ff3c “”, option=0xb4c0ff3c “”, nentries=1000000000,
firstentry=0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/tree/tree/src/TTree.cxx:6080
#21 0xb4bae568 in G__G__Tree_113_0_158 ()
from /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/lib/libTree.so.5.28
#22 0xb69b9ab0 in Cint::G__ExceptionWrapper (
funcp=0xb4baddd9 <G__G__Tree_113_0_158(G__value*, char const*, G__param*, int)>, result7=0xbfc3e940, funcname=0x900bd00 “”, libp=0xbfc342fc, hash=0)
at cint/cint/src/Api.cxx:393
#23 0xb6aaa365 in G__execute_call (result7=0xbfc3e940, libp=0xbfc342fc,
ifunc=0x900bd00, ifn=0) at cint/cint/src/newlink.cxx:2406
#24 0xb6aaad0c in G__call_cppfunc (result7=0xbfc3e940, libp=0xbfc342fc,
ifunc=0x900bd00, ifn=0) at cint/cint/src/newlink.cxx:2610
#25 0xb6a66872 in G__interpret_func (result7=0xbfc3e940,
funcname=0x8929ab8 “Scan”, libp=0xbfc342fc, hash=389, p_ifunc=0x900bd00,
funcmatch=1, memfunc_flag=1) at cint/cint/src/ifunc.cxx:5204
#26 0xb6a53ef4 in G__getfunction (item=0x8efc33f “Scan()”, known3=0xbfc41efc,
memfunc_flag=1) at cint/cint/src/func.cxx:2339
#27 0xb6b657c5 in G__getstructmem (store_var_type=112, varname=
0xbfc41c0c,
membername=0x8efc33f “Scan()”, memnamesize=2147483647,
tagname=0x8927210 “$tree”, known2=0xbfc41efc, varglobal=0xb6c21980,
objptr=2) at cint/cint/src/var.cxx:6763
#28 0xb6b55fca in G__getvariable (item=0x8efc338 “$tree->Scan()”,
known=0xbfc41efc, varglobal=0xb6c21980, varlocal=0x0)
at cint/cint/src/var.cxx:5348
#29 0xb6a1db5f in G__getitem (item=0x8efc338 “$tree->Scan()”)
at cint/cint/src/expr.cxx:1913
#30 0xb6a1e03d in G__getitem (item=0x8926a00 “tree->Scan()”)
at cint/cint/src/expr.cxx:1972
#31 0xb6a337d4 in G__getexpr (expression=0x8944b60 “tree->Scan()”)
at cint/cint/src/expr.cxx:1495
#32 0xb6ac10d0 in G__exec_function (statement=
0xbfc440d0, pc=0xbfc440e4,
piout=0xbfc440e0, plargestep=0xbfc440d8, presult=0xbfc44060)
at cint/cint/src/parse.cxx:644
#33 0xb6ac9a23 in G__exec_statement (mparen=0xbfc44374)
at cint/cint/src/parse.cxx:7134
#34 0xb6a04b8f in G__exec_tempfile_core (file=0x0, fp=0x8efcf20)
at cint/cint/src/debug.cxx:265
#35 0xb6a04f62 in G__exec_tempfile_fp (fp=0x8efcf20)
at cint/cint/src/debug.cxx:807
#36 0xb6adeb0c in G__process_cmd (line=0x8efc260 “tree->Scan()”,
prompt=0x891e864 “”, more=0x891e85c, err=0xbfc4556c, rslt=0xbfc45538)
at cint/cint/src/pause.cxx:3327
#37 0xb71e0614 in TCint::ProcessLine (this=0x891e840,
line=0x8efc260 “tree->Scan()”, error=0x0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/meta/src/TCint.cxx:522
#38 0xb7107d50 in TApplication::ProcessLine (this=0x89e1df0,
line=0x8efc260 “tree->Scan()”, sync=false, err=0x0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/base/src/TApplication.cxx:904
#39 0xb665d07c in TRint::HandleTermInput (this=0x89e1df0)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/rint/src/TRint.cxx:559
#40 0xb665c90e in TTermInputHandler::Notify (this=0x8c82478)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/rint/src/TRint.cxx:127
#41 0xb6660332 in TTermInputHandler::ReadNotify (this=0x8c82478)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/rint/src/TRint.cxx:119
#42 0xb723375a in TUnixSystem::CheckDescriptors (this=0x891af38)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/unix/src/TUnixSystem.cxx:1259
#43 0xb7233edc in TUnixSystem::DispatchOneEvent (this=0x891af38,
pendingOnly=false)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/unix/src/TUnixSystem.cxx:966
#44 0xb7180e17 in TSystem::InnerLoop (this=0x891af38)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/base/src/TSystem.cxx:406
#45 0xb719032d in TSystem::Run (this=0x891af38)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/base/src/TSystem.cxx:356
#46 0xb71036e2 in TApplication::Run (this=0x89e1df0, retrn=false)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/base/src/TApplication.cxx:1052
#47 0xb665e0bd in TRint::Run (this=0x89e1df0, retrn=false)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/rint/src/TRint.cxx:431
#48 0x08048f27 in main (argc=1, argv=0xbfc47a64)
at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/main/src/rmain.cxx:29

Hi Daniel,

Does it crashes if you load the library implementing your derived class?

Cheers,
Philippe.

PS. #10 0xb5999f4d in MvtCubeStats::Streamer () from /u/drichter/share/lib/libMvtCommon.so #11 0xb7140f02 in TObject::SavePrimitive (this=0x914f018, out= 0x1) at /usr/local/pub/debian5.0/i686/gcc432-11/rootmgr/528-00c/core/base/src/TObject.cxx:673 #12 0xb56fe042 in TBufferFile::MapObject (this=0x912be20, obj=0x914f018, offset=1)is very surprising as MapObject does not call SavePrimitives and SavePrimitive does not call Streamer …

It is plausible that there is a problem in the default constructor (missing initialization). I recommend running valgrind on your example.