GetEntry() crash when more than 2000 entries

Hello,

I’m facing a crash probably due to GetEntry() method. I had the same problem with root 5.28 and 5.34.
The macro I’m trying to use is, for the moment, a very simple one.

{
int evtID=0, NDeposits=0;
float dep_E[100];
float dep_E0=0;
int parentPDG=0;

vector filenames;
for(int ii=0;ii<10;ii++){
string file;
file = Form(“new/Th-232_TOP_%d_user.root”,ii);
filenames.push_back(file.c_str());
cout << filenames[ii].c_str() << endl;
}

for(int i=0;i<1;i++){
TFile * infile = new TFile(filenames[i].c_str(), “OPEN”);
cout << filenames[i].c_str()<<endl;

TTree * myTT = (TTree*) infile->Get(“TT”);

myTT->SetBranchAddress(“evtID”,&evtID);
myTT->SetBranchAddress(“NDeposits”,&NDeposits);
myTT->SetBranchAddress(“dep_E”,dep_E);
myTT->SetBranchAddress(“dep_E0”,&dep_E0);

for(int j=0; j GetEntries() ; j++){
myTT->GetEntry(j);
}

myTT-> ResetBranchAddresses();
infile->Close();

}
}

Limiting the number of entry to 2000 (loop on j), it does not crash. However, when I try to extend the loop on the entire rootfile, especially in a loop on many rootfiles, I found a crash at the end of the loop on j, saying:

*** Break *** segmentation violation

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

#0 0x00007f68b100961e in waitpid () from /lib64/libc.so.6
#1 0x00007f68b0f9b609 in do_system () from /lib64/libc.so.6
#2 0x00007f68b30e615c in TUnixSystem::StackTrace() () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCore.so.5.28
#3 0x00007f68b30e3931 in TUnixSystem::DispatchSignals(ESignals) () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCore.so.5.28
#4
#5 0x00007f68b109465a in __strcmp_ssse3 () from /lib64/libc.so.6
#6 0x00007f68b26b2e9c in G__searchvariable () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#7 0x00007f68b26b4da0 in G__getvariable () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#8 0x00007f68b25a5d7c in G__getitem () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#9 0x00007f68b25b14d8 in G__getexpr () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#10 0x00007f68b263ef72 in G__exec_loop(char const*, char*, std::list<G__FastAllocString, std::allocator<G__FastAllocString> > const&) () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#11 0x00007f68b2637440 in G__exec_statement () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#12 0x00007f68b2592154 in G__exec_tempfile_core () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#13 0x00007f68b259248b in G__exec_tempfile () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#14 0x00007f68b264a850 in G__process_cmd () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCint.so.5.28
#15 0x00007f68b30a441d in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCore.so.5.28
#16 0x00007f68b30a3f03 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCore.so.5.28
#17 0x00007f68b300b55a in TApplication::ExecuteFile(char const*, int*, bool) () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCore.so.5.28
#18 0x00007f68b3008acb in TApplication::ProcessLine(char const*, bool, int*) () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libCore.so.5.28
#19 0x00007f68b1ec41ab in TRint::Run(bool) () from /afs/in2p3.fr/throng/t2k/ROOT/v5r28p00n01/Linux-x86_64/lib/root/libRint.so.5.28
#20 0x000000000040102d 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 0x00007f68b109465a in __strcmp_ssse3 () from /lib64/libc.so.6

Root >

Do you have any idea to help me?

Many thanks!

Post here the output of:
myTT->Print();
(Well, a good idea would be to post the root file so one could check it.)

Hello,
since TTree::GetEntries() returns a Long64_t try to use that data type in the loop, excluding any automatic static cast.
Lets say:

(...) for(Long64_t j=0; j <myTT->GetEntries() ; j++){ myTT->GetEntry(j); } (...)
that is more correct since TTree::GetEntry() has a Long64_t argument.
Hope that helps

have fun

Gabriele