Simple event class is crashing at the 2nd event

Hello,

I’ve built a simple Event (with a Track, using TClonesArray) class. My implementaion is based on the classes in ${ROOTSYS}/test/Event.cxx(h)

The crash occurs at the tree Fill() in the 2nd event iteration.

root [0] .L hadronAna.h++g
Info in <TUnixSystem::ACLiC>: creating shared library /u/lsilva/job/analysis/gen2/loopDST_tree/example/./hadronAna_h.so
root [1] .x run.cc
event created ...
++++++ event 0
track 0
track 1
track 2
track 3
track 4
Filling tree
Clering event
++++++ event 1
track 0
track 1
track 2
track 3
track 4

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
    stat_loc=0x7fff0140885c, options=<value optimized out>)
    at ../sysdeps/unix/sysv/linux/waitpid.c:32
#0  0x00007fa75fb4283e in __libc_waitpid (pid=<value optimized out>, 
    stat_loc=0x7fff0140885c, options=<value optimized out>)
    at ../sysdeps/unix/sysv/linux/waitpid.c:32
#1  0x00007fa75fae02c9 in do_system (line=<value optimized out>)
    at ../sysdeps/posix/system.c:149
#2  0x00007fa7609fabc8 in TUnixSystem::StackTrace() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#3  0x00007fa7609f9693 in TUnixSystem::DispatchSignals(ESignals) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#4  <signal handler called>
#5  0x00007fa75df0a916 in int TStreamerInfo::WriteBufferAux<char**>(TBuffer&, char** const&, int, int, int, int) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRIO.so
#6  0x00007fa75de77cd8 in TStreamerInfoActions::GenericVectorPtrWriteAction(TBuffer&, void*, void const*, TStreamerInfoActions::TConfiguration const*) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRIO.so
#7  0x00007fa75de2c3b8 in TBufferFile::ApplySequenceVecPtr(TStreamerInfoActions::TActionSequence const&, void*, void*) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRIO.so
#8  0x00007fa75b4243ea in TBranch::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#9  0x00007fa75b42ca50 in TBranchElement::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#10 0x00007fa75b42c9ee in TBranchElement::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#11 0x00007fa75b42c9ee in TBranchElement::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#12 0x00007fa75b479305 in TTree::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#13 0x00007fa75b4ae420 in G__G__Tree_126_0_54(G__value*, char const*, G__param*, int) () from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#14 0x00007fa75ef5b2e9 in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCint.so.5.34
#15 0x00007fa75ef6deba in G__exec_asm ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCint.so.5.34
#16 0x00007fa75f03466b in T.1386 ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCint.so.5.34
#17 0x00007fa75f030180 in G__exec_statement ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCint.so.5.34
#18 0x00007fa75ef94b27 in G__exec_tempfile_core ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCint.so.5.34
#19 0x00007fa75ef94dfb in G__exec_tempfile ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCint.so.5.34
#20 0x00007fa75f03eaa7 in G__process_cmd ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCint.so.5.34
#21 0x00007fa7609b63b6 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#22 0x00007fa7609b3d33 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#23 0x00007fa76090c928 in TApplication::ExecuteFile(char const*, int*, bool) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#24 0x00007fa76090a223 in TApplication::ProcessLine(char const*, bool, int*) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#25 0x00007fa76055d4cd in TRint::HandleTermInput() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRint.so.5.34
#26 0x00007fa7609f7d1e in TUnixSystem::CheckDescriptors() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#27 0x00007fa7609f8013 in TUnixSystem::DispatchOneEvent(bool) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#28 0x00007fa760970036 in TSystem::InnerLoop() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#29 0x00007fa76097222b in TSystem::Run() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#30 0x00007fa76090823f in TApplication::Run(bool) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libCore.so.5.34
#31 0x00007fa76055e0f5 in TRint::Run(bool) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRint.so.5.34
#32 0x000000000040115c in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007fa75df0a916 in int TStreamerInfo::WriteBufferAux<char**>(TBuffer&, char** const&, int, int, int, int) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRIO.so
#6  0x00007fa75de77cd8 in TStreamerInfoActions::GenericVectorPtrWriteAction(TBuffer&, void*, void const*, TStreamerInfoActions::TConfiguration const*) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRIO.so
#7  0x00007fa75de2c3b8 in TBufferFile::ApplySequenceVecPtr(TStreamerInfoActions::TActionSequence const&, void*, void*) ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libRIO.so
#8  0x00007fa75b4243ea in TBranch::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#9  0x00007fa75b42ca50 in TBranchElement::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#10 0x00007fa75b42c9ee in TBranchElement::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#11 0x00007fa75b42c9ee in TBranchElement::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
#12 0x00007fa75b479305 in TTree::Fill() ()
   from /cvmfs/hades.gsi.de/install/root-5.34.01/lib/libTree.so.5.34
===========================================================

I attach an example to reproduce my problem.

For sure something is wrong in my implementaton, but I cannot see why. Can someone please point me where is the mistake?

Many thanks in advance.

Cheers,
Luís.
example.tgz (1.51 KB)

I’m stucked I’ve seen that my code was downloaded 3 times. Could somebody please give any hint?

Cheers,
Luis.

Hi Luis,

[quote=“lsilva”]I’m stucked I’ve seen that my code was downloaded 3 times. Could somebody please give any hint?
[/quote]
I downloaded your code, but wasn’t able to exactly pin down the problem. It is
related to calling event->Clear() after filling (taking that out at least
let’s your code finish running), but I was confused on whether fgTracks being static
was related.

Hi Honk,

Thanks your reply. :slight_smile:

[quote] It is related to calling event->Clear() after filling (taking that out at least
let’s your code finish running), but I was confused on whether fgTracks being static
was related.[/quote]

Maybe it’s related to the Event::Clear() function, I admit that it is not a very clever implementation. Yet, as you see from the output, on the first iteration the Clear() function works but then it fails on the TTree:Fill() function.

By the way, fgTracks needs to be in this case, by construction ‘static’ (I guess).

So … more hints are gracefully welcome :frowning: