Seg fault at GetEntry(entry) for second TProfile

Hi,

I have a GCC compiled macro using ROOT 5.24/01 locally installed on my Ubuntu 12.04.
The code works great, reads the tree, produces plots. So far so good.
Now, changing it to loop over the two streams, my egamma and my muons, with two TChain * m_chain_e/mu, I get a seg fault after loading the first entry on my second plot.
The program successfully produces the first plot, with both egamma and muons streams. Going on the second plot in my loop, it can’t do the “GetEntry(i)” instruction. Seg fault.
Output at end of this message.

My code on SVN:
svnweb.cern.ch/trac/atlasusr/br … 1-00-00-01

(The main functions are in Root/ProfileMaker.cxx in GetProfile() and MakePlots())

I found a workaround to make it for my deadline but I was advised to report this.

Feel free to contact me for any further information.

Cheers,

Claire


PS: I performed tests, pushing back only the egamma, or the muon, or twice the egamma/muon streams in my streams vector and it was working (line 192 ProfileMaker.cxx). It is only with the egamma+muons that it gives a seg fault.


Starting run_ProfileMaker

===> Plots stored in directory:
/home/davidc/Workarea/files/Plots/ProfilePU/batch_000/plots_084/
===> Filling plot info. Info in file: data/plots.dat
baseMuAllPCR1 Base jets CR1 averageIntPerXing Number of baseline jets 20
baseVxAllPCR1 Base jets CR1 vx_n Number of baseline jets 20

===> Input directory: /home/davidc/Workarea/files/D4PD_AnalysisHiggsbbSUSY/p1328/batch_003/
===> Output directory: /home/davidc/Workarea/files/Plots/ProfilePU/batch_000/plots_084/

Applying ATLAS style settings…

===> LOOPING OVER ALL PLOTS - START

[baseMuAllPCR1] ...
=====> Looping on 30370 entries | Stream egamma
	Before getting first entry
	After getting first entry
=====> Looping on 26124 entries | Stream muons
	Before getting first entry
	After getting first entry

[baseVxAllPCR1] ...
=====> Looping on 30370 entries | Stream egamma
	Before getting first entry

*** Break *** segmentation violation

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

#0 0x00007fd11e8dd44e in waitpid () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007fd11e86329e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007fd123928ab7 in TUnixSystem::StackTrace() () from /home/davidc/ROOT/root/lib/libCore.so
#3 0x00007fd12392b393 in TUnixSystem::DispatchSignals(ESignals) () from /home/davidc/ROOT/root/lib/libCore.so
#4
#5 0x00007fd122997bf2 in TBufferFile::ReadFastArray(void*, TClass const*, int, TMemberStreamer*, TClass const*) () from /home/davidc/ROOT/root/lib/libRIO.so
#6 0x00007fd1229e2cf5 in int TStreamerInfoActions::ReadSTL<&TStreamerInfoActions::ReadSTLMemberWiseSameClass, &TStreamerInfoActions::ReadSTLObjectWiseFastArray>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /home/davidc/ROOT/root/lib/libRIO.so
#7 0x00007fd122996d65 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) () from /home/davidc/ROOT/root/lib/libRIO.so
#8 0x00007fd121127c68 in TBranchElement::ReadLeavesMember(TBuffer&) () from /home/davidc/ROOT/root/lib/libTree.so
#9 0x00007fd12112666f in TBranch::GetEntry(long long, int) () from /home/davidc/ROOT/root/lib/libTree.so
#10 0x00007fd121130fa0 in TBranchElement::GetEntry(long long, int) () from /home/davidc/ROOT/root/lib/libTree.so
#11 0x00007fd12116fd2c in TTree::GetEntry(long long, int) () from /home/davidc/ROOT/root/lib/libTree.so
#12 0x000000000040d0b5 in ProfileMaker::GetProfile(ProfileMaker::plot const&, TString const&, TString const&) ()
#13 0x000000000040e7f7 in ProfileMaker::MakePlots() ()
#14 0x000000000040b546 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
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 0x00007fd122997bf2 in TBufferFile::ReadFastArray(void*, TClass const*, int, TMemberStreamer*, TClass const*) () from /home/davidc/ROOT/root/lib/libRIO.so
#6 0x00007fd1229e2cf5 in int TStreamerInfoActions::ReadSTL<&TStreamerInfoActions::ReadSTLMemberWiseSameClass, &TStreamerInfoActions::ReadSTLObjectWiseFastArray>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /home/davidc/ROOT/root/lib/libRIO.so
#7 0x00007fd122996d65 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) () from /home/davidc/ROOT/root/lib/libRIO.so
#8 0x00007fd121127c68 in TBranchElement::ReadLeavesMember(TBuffer&) () from /home/davidc/ROOT/root/lib/libTree.so
#9 0x00007fd12112666f in TBranch::GetEntry(long long, int) () from /home/davidc/ROOT/root/lib/libTree.so
#10 0x00007fd121130fa0 in TBranchElement::GetEntry(long long, int) () from /home/davidc/ROOT/root/lib/libTree.so
#11 0x00007fd12116fd2c in TTree::GetEntry(long long, int) () from /home/davidc/ROOT/root/lib/libTree.so
#12 0x000000000040d0b5 in ProfileMaker::GetProfile(ProfileMaker::plot const&, TString const&, TString const&) ()
#13 0x000000000040e7f7 in ProfileMaker::MakePlots() ()
#14 0x000000000040b546 in main ()

Try to use “valgrind”:

[url]Free(): invalid next size(fast)//malloc(): memory corruption
[url]Upper limit of entries in one bin and in whole histogram
[url]fTotBytes error
[url]Segmentation Fault in Recursive Removement
[url]Memory leak

P.S. I think your source code needs to be compiled with the debug option (e.g. “-g”) in order to get it really usable with the debugger / valgrind.