I’m working with a root-generated class from one of my ntuples. Recently, I’ve been repeatedly running into segmentation fault errors due to arrays that are out of bounds. I have isolated the problem to the innermost loop. In it, I go from 0 to fChain->GetEntry(jentry)-1, and run functions that access the automatically-generated arrays of data at that index. And clues as to why it goes out of bounds?
cout << "Loop is called; getting entries...\n";
if (fChain == 0){ cout << "fChain == 0!\n"; return;}
Long64_t nentries = fChain->GetEntries();
cout << "nentries: " << nentries << endl;
int onePercent = nentries/100;
Int_t nbytes = 0, nb = 0, percentcounter=0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
if (jentry%onePercent == 0) cout << (percentcounter++) << "% done" << endl;
Long64_t ientry = LoadTree(jentry);
if (ientry < 0)
{ cout << "ientry less than 0" <<endl>GetEntry(jentry);
nbytes += nb;
//if (Cut(ientry) < 0) continue; THIS STAYS COMMENTED
for (Int_t ib=0;ib<nb;ib++){
if(CutLargeRegion(ib))
MakeCombinedMassHist(ib); //add data at ib to histogram
}
}
}
Any ideas?
Best,
Danny