I’m running a modified version of the field02 example but when I do a /run/beamOn 200 it crashes frequently showing an error “libc++abi: terminating due to uncaught exception of type std::bad_alloc: std::bad_alloc”. This seems to occur when the KineE property drops to 134/133 eV. My vis.mac file is unchanged.
Is it possible to change the vis.mac file so it doesn’t tell it to raise an exception?
Apologies for not having a better understanding of the vis.mac file.
How and where did you modify the example? Does the stock version run correctly? Have you run your modified code through lldb to trace the source of the exception?
The modified example is running heavy ions as opposed to electrons (I changed from gun to GPS) and the path lengths are very much longer than the unmodified example and the modified example seems to be raising an exception due to these much longer path lengths. Indeed, it becomes tricky if I “/run/beamOn 200” and I’m unable to get any decent stats for such a short run and the stock version runs fine.
I’ve not used a debugger on this example (I have some experience with debuggers). I wouldn’t know where to place break or watchpoints.
I don’t think you’d need to worry about break/watch points intially - I’d guess you can still get a backtrace after the uncaught exception?
Otherwise, maybe see if you can find a single input event that causes the problem, then up the verbosity of tracking to /tracking/verbose 1 (or 2…) and see that provides any more helpful info.
Are you reseeding the RNG on each run? If not, then 1 event might not be sufficient as it’ll be seeded the same each time and not trigger the issue. Alternately, you could output the RNG state at each event to determine that which will trigger the error on the next event.
//choose the Random engine CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); //set random seed with clock time G4long seed = time(NULL); CLHEP::HepRandom::setTheSeed(seed);