Field02 example raising exception

_Geant4 Version: 11.0.0
_Operating System:_Sonoma 14.3
_Compiler/Version: X code 15.3
_CMake Version:_3.29.2

Hi all,

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.

Regards

Tim


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?

Hi Ben,

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.

Regards

Tim

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.

Hi Ben,

I have tried /run/beamOn 1 repeatedly but it hasn’t, thus far raised the same exception. I’ll keep trying…

Regards

Tim

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.

Hi Ben,

I have done the random seeded modification (see below) so it shouldn’t be using the same seed.

Also, reading through some previous issues I notice that this: Segmentation fault when using low energy and electric field seems to be a similar issue if cghw02 is using the field02 example which he alludes to in another thread.

T

//choose the Random engine
CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
//set random seed with clock time
G4long seed = time(NULL);
CLHEP::HepRandom::setTheSeed(seed);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.