Adding decays from multiple isotopes to rdecay02 example

I’m new to Geant4 and running a simulation based on the rdecay02 example. I’ve changed the generated primary particle to a gamma as I require and distributed it uniformly throughout the target volume.

The issue I’m encountering is when I try to add decays from internal background contamination that my material would realistically have, the simulation crashes (Segmentation Fault) on beamOn, and from what I’ve seen it seems to crash when I generate a second event with a primary vertex.

But the question I have more generally I think, and for which there might be a simpler answer, is how can I generate multiple primary particles of different types within a single event, in my case I wish to generate a gamma and a decay of some internal radioactive contamination (say U-238) at the same event (the gamma would be produced every event and the decay occasionally based on a probability derived from the activity). Thanks.

You may have a look to example extended/eventgenerator/particleGun : PrimaryGeneratorAction1