No error when macro crashes


I’m writing a macro that uses a 2D array. But the program just stops when declaring the array. There’s no error or seg fault message. This is how I start the macro:

root -q ‘analysis/particleIDAnl/findLightSpread.C++(,,size)’

Here’s the relevant code:

// headers

void findLightSpread(const char* infile, const char* outfile, const int size) {

const int fiberNum = 768;
const int numOfVoxels = sizesizesize;

Double_t totalPE[fiberNum][numOfVoxels];

for(int i=0;i<numOfVoxels;i++)
for(int j=0; j<fiberNum;j++)
totalPE[i][j] = 0;


The macro stops at the line: Double_t totalPE[fiberNum][numOfVoxels];

Here’s the output. The warnings are due to the header files:

[quote]-bash-3.2$ root -q 'analysis/particleIDAnl/findLightSpread.C++(“scibathMC/output/Ialpha_1.root”,“analysis/particleIDAnl/spreadFun1.root”,16)'
Loading SciBath Root Utilities
include path: -I/usr/local/share/cern/root/5.27.02/include -I/nfs/festus/home/lorebeni/ScibathCode/scibathAnl/install/include
root [0]
Processing analysis/particleIDAnl/findLightSpread.C++(“scibathMC/output/Ialpha_1.root”,“analysis/particleIDAnl/spreadFun1.root”,16)…
Info in TUnixSystem::ACLiC: creating shared library /nfs/festus/home/lorebeni/ScibathCode/scibathAnl/./analysis/particleIDAnl/
/nfs/festus/home/lorebeni/ScibathCode/scibathAnl/install/include/SBHitInformation.h:40: warning: unused parameter ‘i’
/nfs/festus/home/lorebeni/ScibathCode/scibathAnl/install/include/SBClasses.h:55: warning: unused parameter ‘i’

There’s supposed to be an output file, but that file is not created, so I know the program is stopping at that line. What would cause this?


Nothing in the “output”, that you show in your post, suggests that your macro “died” in any way.

Try to add some “debug” lines, e.g.: std::cout << "Before totalPE" << std::endl << std::flush; Double_t totalPE[fiberNum][numOfVoxels]; std::cout << "After totalPE" << std::endl << std::flush;
There is just one possible problem in the line that you suspect.
Your “Double_t totalPE[768][161616];” is 24MB long.
It is possible that this exceeds your stack size “limit”. Try:
[bash]$ ulimit -S -a
[bash]$ ulimit -H -a
[tcsh]$ limit
[tcsh]$ limit -h
If this is the case, try (note: your new “soft limit” cannot be higher than the “hard limit”):
[bash]$ ulimit -S -s 32768
[tcsh]$ limit stacksize 32768
and then try to run your “root -q …” command again.