Segmentation violation in cloning trees

Hello all,

I am trying to clone some event from 6 trees.
They way I am doing is:

TChain t("myEvent"); t.Add(<filenames>); TTree *nt=(TTree*)t.CloneTree(nevents);

All 6 trees combined have 1518115 events.
If I give nevents = 100, 1000 or 10000, it works well.
If I give 50000, then it gives me segmentation violation[1]

Any help is appreciated.

Best Regards,
Shilpi

[1]
[color=#FF0040]===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x000000360b29a115 in waitpid () from /lib64/libc.so.6
#1 0x000000360b23c481 in do_system () from /lib64/libc.so.6
#2 0x00002ac2ba7b8222 in TUnixSystem::StackTrace() ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#3 0x00002ac2ba7b8cdc in TUnixSystem::DispatchSignals(ESignals) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#4
#5 0x00002ac2bbfffd00 in TBranch::GetEntry(long long, int) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#6 0x00002ac2bc047180 in TTree::GetEntry(long long, int) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#7 0x00002ac2bc04d93f in TTree::CopyEntries(TTree*, long long, char const*) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#8 0x00002ac2bc04f2a8 in TTree::CloneTree(long long, char const*) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#9 0x00002ac2bc0d2428 in G__G__Tree_110_0_35(G__value*, char const*, G__param*, int) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#10 0x00002ac2bad22114 in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#11 0x00002ac2badd8a70 in G__execute_call ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#12 0x00002ac2badd9879 in G__call_cppfunc ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#13 0x00002ac2badb83d6 in G__interpret_func ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#14 0x00002ac2bada6274 in G__getfunction ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#15 0x00002ac2bae8b556 in G__getstructmem ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#16 0x00002ac2bae80990 in G__getvariable ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#17 0x00002ac2bad7907f in G__getitem ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#18 0x00002ac2bad7db54 in G__getexpr ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#19 0x00002ac2bada5bea in G__getfunction ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#20 0x00002ac2bad7980a in G__getitem ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#21 0x00002ac2bad7db54 in G__getexpr ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#22 0x00002ac2bad6a43a in G__define_var ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#23 0x00002ac2bae02c39 in G__exec_statement ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#24 0x00002ac2bad652dc in G__exec_tempfile_core ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#25 0x00002ac2bad655be in G__exec_tempfile_fp ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#26 0x00002ac2bae132f2 in G__process_cmd ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCint.so
#27 0x00002ac2ba77a705 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#28 0x00002ac2ba6d61ba in TApplication::ProcessLine(char const*, bool, int*) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#29 0x00002ac2bb8c2008 in TRint::HandleTermInput() ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libRint.so
#30 0x00002ac2ba7b6214 in TUnixSystem::CheckDescriptors() ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#31 0x00002ac2ba7b6830 in TUnixSystem::DispatchOneEvent(bool) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#32 0x00002ac2ba734636 in TSystem::InnerLoop() ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#33 0x00002ac2ba73667c in TSystem::Run() ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#34 0x00002ac2ba6d40ef in TApplication::Run(bool) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libCore.so
#35 0x00002ac2bb8c3d28 in TRint::Run(bool) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libRint.so
#36 0x000000000040100d 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 0x00002ac2bbfffd00 in TBranch::GetEntry(long long, int) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#6 0x00002ac2bc047180 in TTree::GetEntry(long long, int) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#7 0x00002ac2bc04d93f in TTree::CopyEntries(TTree*, long long, char const*) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so
#8 0x00002ac2bc04f2a8 in TTree::CloneTree(long long, char const*) ()
from /uscmst1/prod/sw/cms/slc5_amd64_gcc434/lcg/root/5.27.06b-cms21/lib/libTree.so

==============================================[/color]

Please note that I am cloning tree to combine two trees using different events.
i.e. I have a tree1 and tree2 with total entries as nev1 and nev2.
I want to combine the two trees by taking nentreis1 from the first tree and nentreis2 from the second.
I am using CloneTree for this purpose.

Is there a better way of doing this?

Thanks,
Shilpi

Hi,

Does it matter which files are in the chain? Is the output TTree stored in a (new) file? What is the result of running your failing example with valgrind?

Philippe.

Hi,

Try to save cloned tree to the file, it should help.

Hi Philippe, Leszczo,

Many thanks for your reply. I was not saving the trees in the
file. I did that step and that error is solved.

Thanks for the suggestions,
Shilpi