"Event Must Be Aborted" during tracking seems to cause segfault

Geant4 Version: 10.07.p04
Operating System: macOS Tahoe
Compiler/Version: Apple Clang 17.0.0
CMake Version: 4.2.1


We’ve been running into this for a while, but trying to fix the underlying errors rather than this segfault. At several places in our simulation code, we do sanity checks and stop the event if something sufficiently unpleasant happens.

What I’ve noticed is that when we do this, we get a very nice additional dump of the particle step where the exception happened, and then there is a segfault and the job crashes. The traceback shows the segfault in the function the called G4Exception (i.e., usually in our simulation framework code), rather than wherever the real segfault was.

Is this something other people have seen? If so, any suggestions on where we should be looking to address it?

1 Like

Okay, this turns out to be our fault (the segfault, that is). We have functions which create secondary tracks for interactions in an encapsulated way. If the input arguments are invalid, we generate a G4Exception with EventMustBeAborted, and have a return nullptr; after that.

I’ve always assumed that the “abort” exceptions would redirect things, and stop the event right where it is. But that’s not true. The G4Exception returns, so the null pointer gets passed up the chain, and our other code doesn’t check for validity. So now I’ve got an internal issue opened to fix that.

1 Like

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