fChain->GetEntry() problem

Hello everyone,

I would need to have an advice about a problem I am facing in my code.
I have a series of ROOT macros that crash when trying to open a file.
I would appreciate a comment on the way it crashes i.e. whether more experienced people can have a feeling about what can be causing the problem.
I am using ROOT version 5.14. I have a TTree called fChain that is

The crash happens when one gets to the line:
Long64_t centry = fChain->LoadTree(entry);
I also have a crash when I try to do int pippo = fChain->GetEntry(entry)

I know I should make info available for this to be reproducible, but I am mor einterested into a hint: what can make a TTree crash with segmentation faul? What bad things can one be doing with the memory?
Sorry I know this is like asking to fathom the content of a black box…I’ll try to make more info available (and reproducible) vailable if I have made no additional progress.

The outcome of running the macro is below:

Note: File “/usr/nevis/root-05.14.00/lib/libHist.so” already loaded
Note: File “/a/home/kolya/fspano/topanalysis/src/./…/HitFit/CLHEP/lib/libCLHEP.so” already loaded
Note: File “/usr/nevis/root-05.14.00/lib/libMatrix.so” already loaded
Note: File “/usr/nevis/root-05.14.00/lib/libTree.so” already loaded
Note: File “/usr/nevis/root-05.14.00/lib/libPhysics.so” already loaded
FileList::Generating FileList object
LoadFileList::reading info in listsTopView1214/files_ttbarnohad_1214_smallone.txt
LoadFileList::Number of lines in file is1
LoadFileList::reading filenames in is over
FileList::files’ names are stored
FillFileDim::filling the file dimension
FillFileDim::the element in list is /data/TopData1214/5200/user.top.TopViewCSC121403_StacoTauRec_30um.trig1_misal1_mc12.005200.T1_McAtNlo_Jimmyv12000604.001.AANT0._00161.root
Warning in TClass::TClass: no dictionary for class AttributeListLayout is available
Warning in TClass::TClass: no dictionary for class pair<string,string> is available
FillFileDim::I have 3750events
FillFileDim::file closed
FileList::files’ dimensions are stored
FileList::event weight based on file dimensions are calculated and stored
TopIO::Init::adding/data/TopData1214/5200/user.top.TopViewCSC121403_StacoTauRec_30um.trig1_misal1_mc12.005200.T1_McAtNlo_Jimmyv12000604.001.AANT0._00161.root as file no0for top analysis
TopIO::Init::I have 3750 in the 0th file
TopIO::Init::I have 1 files in the chain
TopIO::Init::adding FullRecoAna0
TopIO::Init::adding TruthAna0
TopIO::Init::with 3750 events for friend in the chain
TopIO::Init::with 3750 events in the chain
TopIO::Init::the reco tree isFullReco0
TopIO::Start:: I am starting
TopIO::Start::Before setting branch addresses
TopIO::Start::Before setting up branch addresses from FullRecoAna
TopIO::truth is set up
TopIO:Start:getting W related info
getting W related info
TopIO::Start:getting Zprime related info: at the end
TopIO::Start:just before fchan
TopIO::Start:fChain has 3750entries
TopIO::Start:in entry 4 LepTop_N =0
TopIO::Start:in entry 4 LepTop_N_True =0
TopIO::just before Notify
TopIO:Init::initialization for TopIO is complete
NtupleMaker::GenerateNtup::filettbarnohadhistos_1214.root is open!
NtupleMaker::GenerateNtup::ntuple structre is set upttbarnohadhistos_1214.root
PROCESSING EVENT no 0
TopIO::loadentry-------bef Loading the tree info
TopIO::LoadTree:loading stuff
TopIO::LoadTree:loading the tree

*** Break *** segmentation violation
(no debugging symbols found)
Attaching to program: /proc/23398/exe, process 23398
(no debugging symbols found)…done.
(no debugging symbols found)…done.
[Thread debugging using libthread_db enabled]
[New Thread 0xb7fff6c0 (LWP 23398)]
0x00110416 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install glibc.i686 libX11.i386 libXau.i386 libXcursor.i386 libXdmcp.i386 libXext.i386 libXfixes.i386 libXpm.i386 libXrender.i386 libxcb.i386
#1 0x06cb0233 in __waitpid_nocancel () from /lib/libc.so.6
#2 0x06c4e59b in do_system () from /lib/libc.so.6
#3 0x00a4303d in system () from /lib/libpthread.so.0
#4 0x003cf349 in TUnixSystem::Exec () from /usr/nevis/root-05.14.00/lib/libCore.so
#5 0x003cf7f4 in TUnixSystem::StackTrace () from /usr/nevis/root-05.14.00/lib/libCore.so
#6 0x003cd5b7 in TUnixSystem::DispatchSignals () from /usr/nevis/root-05.14.00/lib/libCore.so
#7 0x003cb404 in SigHandler () from /usr/nevis/root-05.14.00/lib/libCore.so
#8 0x003d211e in sighandler () from /usr/nevis/root-05.14.00/lib/libCore.so
#9
#10 0x059aaf05 in TChain::LoadTree () from /usr/nevis/root-05.14.00/lib/libTree.so
#11 0x04795382 in TopIO::LoadTree () from /a/home/kolya/fspano/topanalysis/src/./topntupmake_cpp.so
#12 0x047a2170 in TopIO::loadentry () from /a/home/kolya/fspano/topanalysis/src/./topntupmake_cpp.so
#13 0x047af60d in topntupmake () from /a/home/kolya/fspano/topanalysis/src/./topntupmake_cpp.so
#14 0x047b2028 in G__fileVb2zGZ__0_3294 () from /a/home/kolya/fspano/topanalysis/src/./topntupmake_cpp.so
#15 0x00ac8009 in Cint::G__ExceptionWrapper () from /usr/nevis/root-05.14.00/lib/libCint.so
#16 0x00ba6358 in G__call_cppfunc () from /usr/nevis/root-05.14.00/lib/libCint.so
#17 0x00b91f0e in G__interpret_func () from /usr/nevis/root-05.14.00/lib/libCint.so
#18 0x00b76a36 in G__getfunction () from /usr/nevis/root-05.14.00/lib/libCint.so
#19 0x00b69e50 in G__getitem () from /usr/nevis/root-05.14.00/lib/libCint.so
#20 0x00b67a71 in G__getexpr () from /usr/nevis/root-05.14.00/lib/libCint.so
#21 0x00bc2c0e in G__exec_function () from /usr/nevis/root-05.14.00/lib/libCint.so
#22 0x00bcd62f in G__exec_statement () from /usr/nevis/root-05.14.00/lib/libCint.so
#23 0x00b93cef in G__interpret_func () from /usr/nevis/root-05.14.00/lib/libCint.so
#24 0x00b76a36 in G__getfunction () from /usr/nevis/root-05.14.00/lib/libCint.so
#25 0x00b69e50 in G__getitem () from /usr/nevis/root-05.14.00/lib/libCint.so
#26 0x00b67a71 in G__getexpr () from /usr/nevis/root-05.14.00/lib/libCint.so
#27 0x00bc2c0e in G__exec_function () from /usr/nevis/root-05.14.00/lib/libCint.so
#28 0x00bcd62f in G__exec_statement () from /usr/nevis/root-05.14.00/lib/libCint.so
#29 0x00b456a9 in G__exec_tempfile_core () from /usr/nevis/root-05.14.00/lib/libCint.so
#30 0x00b45971 in G__exec_tempfile_fp () from /usr/nevis/root-05.14.00/lib/libCint.so
#31 0x00bd7547 in G__process_cmd () from /usr/nevis/root-05.14.00/lib/libCint.so
#32 0x00324a73 in TCint::ProcessLine () from /usr/nevis/root-05.14.00/lib/libCore.so
#33 0x002475b8 in TApplication::ProcessLine () from /usr/nevis/root-05.14.00/lib/libCore.so
#34 0x009e1044 in TRint::HandleTermInput () from /usr/nevis/root-05.14.00/lib/libRint.so
#35 0x009df5ab in TTermInputHandler::Notify () from /usr/nevis/root-05.14.00/lib/libRint.so
#36 0x009e14fe in TTermInputHandler::ReadNotify () from /usr/nevis/root-05.14.00/lib/libRint.so
#37 0x003cda49 in TUnixSystem::CheckDescriptors () from /usr/nevis/root-05.14.00/lib/libCore.so
#38 0x003cc7b4 in TUnixSystem::DispatchOneEvent () from /usr/nevis/root-05.14.00/lib/libCore.so
#39 0x002d2fbc in TSystem::InnerLoop () from /usr/nevis/root-05.14.00/lib/libCore.so
#40 0x002d2f55 in TSystem::Run () from /usr/nevis/root-05.14.00/lib/libCore.so
#41 0x00247e33 in TApplication::Run () from /usr/nevis/root-05.14.00/lib/libCore.so
#42 0x009e09b0 in TRint::Run () from /usr/nevis/root-05.14.00/lib/libRint.so
#43 0x08048d71 in main ()
The program is running. Quit anyway (and detach it)? (y or n) [answered Y; input not from terminal]
Detaching from program: /proc/23398/exe, process 23398
Root > Function runtoptest() busy flag cleared

Now I have all that is necessary to reproduce the problem in a public area.
Can someone have a look? Maybe it is a banal thing

I crash when I try to do
int pippo=fChain->GetEntry(0)
i.e. when , after setting all the branch addresses I try to access the entry.

In my public area
/afs/cern.ch/user/s/spano/public/forROOT

I have TopIO.cpp and TopIO.h.

The file to use is on lxplus250 in /tmp/spano.

What Id:

  1. I connect to lxplus250

  2. I go to my public area and I start root (I am now using ROOT 5.20/00, I was using 5.14 but the problem stays the same)

  3. I compile .L TopIO.cpp++

  4. I try to generate an object of type TopIO with the following recipe (it needs to be all on one line of course)

TopIO* MyTopInfo = new TopIO("/tmp/spano/user.top.TopViewCSC121403_StacoTauRec_30um.trig1_misal1_mc12.005200.T1_McAtNlo_Jimmyv12000604.001.AANT0._00320.root",“FullReco0”,“FullRecoAna0”, “TruthAna0”, “MC”);

  1. I get the following crash
    Warning in TClass::TClass: no dictionary for class AttributeListLayout is available
    Warning in TClass::TClass: no dictionary for class pair<string,string> is available
    TopIO::Init::I have 1200 in the 0th file
    TopIO::Init::I have 1 files in the chain
    TopIO::Init::adding FullRecoAna0
    TopIO::Init::adding TruthAna0
    TopIO::Init::with 1200 events for friend in the chain
    TopIO::Init::with 1200 events in the chain
    TopIO::Init::the reco tree isFullReco0
    TopIO::Start:: I am starting
    TopIO::Start::Before setting branch addresses
    TopIO::Start::Before setting up branch addresses from FullRecoAna
    TopIO::truth is set up
    TopIO:Start:getting W related info
    getting W related info
    TopIO::Start:getting Zprime related info: at the end
    TopIO::Start:just before fchan
    TopIO::Start:fChain has 1200entries

*** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library “/lib64/tls/libthread_db.so.1”.
Attaching to program: /proc/21531/exe, process 21531
(no debugging symbols found)…done.
(no debugging symbols found)…done.
[Thread debugging using libthread_db enabled]
[New Thread 182918475488 (LWP 21531)]
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
0x000000314898fb74 in waitpid
() from /lib64/tls/libc.so.6
#1 0x0000003148939bcf in do_system () from /lib64/tls/libc.so.6
#2 0x0000002a957abfdd in TUnixSystem::StackTrace ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#3 0x0000002a957a8cea in TUnixSystem::DispatchSignals ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#4
#5 0x0000002a991d1f45 in TChain::LoadTree ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libTree.so
#6 0x0000002a991d10dc in TChain::GetEntry ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libTree.so
#7 0x0000002a9997de9a in TopIO::Start () from /afs/cern.ch/user/s/spano/public/forROOT/./TopIO_cpp.so
#8 0x0000002a9998164b in TopIO::Init () from /afs/cern.ch/user/s/spano/public/forROOT/./TopIO_cpp.so
#9 0x0000002a99980825 in TopIO::Init () from /afs/cern.ch/user/s/spano/public/forROOT/./TopIO_cpp.so
#10 0x0000002a99980aa1 in TopIO::TopIO () from /afs/cern.ch/user/s/spano/public/forROOT/./TopIO_cpp.so
#11 0x0000002a99980d8e in G__fileECeEIA_2346_0_2 () from /afs/cern.ch/user/s/spano/public/forROOT/./TopIO_cpp.so
#12 0x0000002a95e2af84 in Cint::G__ExceptionWrapper ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#13 0x0000002a95ed27ec in G__execute_call ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#14 0x0000002a95ed2aa2 in G__call_cppfunc ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#15 0x0000002a95eb45b2 in G__interpret_func ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#16 0x0000002a95ea226b in G__getfunction ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#17 0x0000002a95ed0eb2 in G__new_operator ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#18 0x0000002a95e7ad5d in G__getexpr ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#19 0x0000002a95e69cea in G__define_var ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#20 0x0000002a95f0023f in G__exec_statement ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#21 0x0000002a95e646e4 in G__exec_tempfile_core ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#22 0x0000002a95e65b3e in G__exec_tempfile_fp ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#23 0x0000002a95f114a1 in G__process_cmd ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCint.so
#24 0x0000002a9579278f in TCint::ProcessLine ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#25 0x0000002a956d8085 in TApplication::ProcessLine ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#26 0x0000002a96b605a5 in TRint::HandleTermInput ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libRint.so
#27 0x0000002a96b5ed17 in TTermInputHandler::Notify ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libRint.so
#28 0x0000002a96b60dcd in TTermInputHandler::ReadNotify ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libRint.so
#29 0x0000002a957a51b3 in TUnixSystem::CheckDescriptors ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#30 0x0000002a957a9329 in TUnixSystem::DispatchOneEvent ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#31 0x0000002a95731545 in TSystem::InnerLoop ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#32 0x0000002a957312fa in TSystem::Run ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#33 0x0000002a956d815f in TApplication::Run ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libCore.so
#34 0x0000002a96b5f471 in TRint::Run ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.20.00/slc4_amd64_gcc34/root/lib/libRint.so
#35 0x000000000040107d in main ()
Root >

The problem is in the AddFriend function:

I am defining

char* recotree;
char* anarecotree;
char* mctruetree;
TChain *chainmctruth;
TChain *chainrec ;
TChain *chainanarec
in the TopIO.h file

then in the TopIO.cpp I have

chainmctruth= new TChain(mctruetree);
chainanarec = new TChain(anarecotree);
chainrec = new TChain(recotree);

where the strings are filled.

Then I try to do
chainrec->AddFriend(anarecotree);
chainrec->AddFriend(mcrecoanatree);

This causes a crash when I define

TTree* fChain=chainrec;
fChain->GetEntry (4)

Does anyone understand why?

your data file is not reachable

code [129] cd /tmp/spano
-bash: cd: /tmp/spano: Permission denied
[/code]

Rene