The program crashes when G4ReactionDynamics::GenerateXandPt() is called with vecLen == 0. I don't understand the code well enough to know if vecLen=0 is an invalid input, but most of the routine is protected against it. However the block: // DEBUGGING --> DumpFrames::DumpFrame(vec, vecLen); if( backwardParticlesLeft == 0) { backwardEnergy += targetParticle.GetMass()/GeV; targetParticle = *vec[0]; --backwardCount; for( G4int j=0; j<(vecLen-1); ++j )*vec[j] = *vec[j+1]; //G4ReactionProduct *temp = vec[vecLen]; //delete temp; if( --vecLen == 0 )return false; // all the secondaries have been eliminated break; } is not protected against vecLen == 0. It crashes on the assignment of *vec[0] to targetParticle. If it did not crash here, it would get in more trouble when it executed the --vecLen instruction and vecLen became negative, I think. From a fairly naive analysis of the code, it looks to me like the routine should return if vecLen==0 before the statement: while( forwardEnergy <= 0.0 ) // must eliminate a particle from the forward side Above this instruction there appear to be possibilities for vecLen to increase; below it, particles can only be removed, and whenever --vecLen yields 0 after this point the routine does in fact return.
I'll have to leafe through it in more detail, but it seems to be indeed a protection missing for the case where GenerateXandPt is called, while no particle was created. Thank you for spotting this one.
Fixed. To be released in the next reference tag.