Secondary Particle track

Hello to all
I’m new to geant4
I tried to simulate the x-ray fluorescence phenomenon in order to see the detector response. I successfully built the geometry and implemented the samples myself.
I set the cut-off value to 500nm
However, I have some difficulties that arise during the simulation
-If I run 100 particles, the code runs smoothly but if I increase the number of runs to 1000 or 10000 I have a segmentation fault (I remind you that I do not use the G4Multithreaded). If the run works normally (case of 100), in the root file I get the number of particles produced in the sample. However what comes out of the sample does not reach the detector, so no energy is deposited in the detector or the number of particles.
Could someone help me understand why what comes out of the sample does not reach the detector?
Please let me know if I can refer to an example or code of some kind to track the secondary particle so that it reaches the detector.