Seg fault with large value of nb=fChain->GetEntry(jentry)

I am using Loop() method running over some input files and filling a new tree in a root file.

I notice that for a particular event where
nb = fChain->GetEntry(jentry);
is very large my code give seg. fault at the following line:
outfile->cd(); //<–here outfile is my output root file

Few cout statments are given below for the value of nb :
nb =1903
nb =8659
nb =29809 //<----for this value it breaks at outfile->cd();

Any Idea how I can avoid this breaking without throwing away this entry? Is there a limit on nb when we are reading from a file??

with best regards,


we cannot help you without seeing your actual code nor the backtrace you get nor the error message you get. The number of bytes read is not the issue by itself.

Cheers, Axel.

Hi ,

The file is here:

The seg fault is this:

nb =29809
now Fill
*** Break *** segmentation violation
Attaching to program: /proc/32707/exe, process 32707
[Thread debugging using libthread_db enabled]
0xffffe405 in __kernel_vsyscall ()
#1 0x005dd713 in __waitpid_nocancel () from /lib/
#2 0x0058207b in do_system () from /lib/
#3 0x006b4ead in system () from /lib/
#4 0xf6220b0d in TUnixSystem::Exec(char const*) ()
from /uscmst1/prod/sw/cms/slc5_ia32_gcc434/cms/cmssw/CMSSW_3_8_7/external/slc5_ia32_gcc434/lib/
#5 0xf6225fab in TUnixSystem::StackTrace() ()
from /uscmst1/prod/sw/cms/slc5_ia32_gcc434/cms/cmssw/CMSSW_3_8_7/external/slc5_ia32_gcc434/lib/
#6 0xf6226d7d in TUnixSystem::DispatchSignals(ESignals) ()
from /uscmst1/prod/sw/cms/slc5_ia32_gcc434/cms/cmssw/CMSSW_3_8_7/external/slc5_ia32_gcc434/lib/
#7 0xf6226e7d in SigHandler(ESignals) ()
from /uscmst1/prod/sw/cms/slc5_ia32_gcc434/cms/cmssw/CMSSW_3_8_7/external/slc5_ia32_gcc434/lib/
#8 0xf621d782 in sighandler(int) ()
from /uscmst1/prod/sw/cms/slc5_ia32_gcc434/cms/cmssw/CMSSW_3_8_7/external/slc5_ia32_gcc434/lib/
#10 0x0805e7f1 in myCuts::Loop() ()
#11 0x080699cf in main ()
A debugging session is active.

Inferior 1 [process 32707] will be detached.

Quit anyway? (y or n) [answered Y; input not from terminal]
Detaching from program: /proc/32707/exe, process 32707

Note: I do outfile->cd() insdie the event loop before filling the tree beacuse I read two other trees to get some informaiton and then close them.

best regards,

i also check the input file and its not currepted etc… There are some other file related to this code at the same web-link.

best regards,


My guess is that some of your files have more than 100 elements in their array. Update the declaration to be larger arrays. (You can also try to run valgrind on your example to see what the issue really is).



You mean the element I am writing in the output tree or the one I am reading???

For writing to output file i have array size 100 but I write only first two elemnts!!

With best,

just found in one element the entries were more than declared.

Code is working now.

Thanks a lot for your help.

Best regards,