| Summary: | Geant4 code calls abort() and exit() | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Tom Roberts <tjrob> |
| Component: | global | Assignee: | Gabriele Cosmo <Gabriele.Cosmo> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P5 | ||
| Version: | 9.5 | ||
| Hardware: | All | ||
| OS: | All | ||
A related issue is this error:
ERROR - G4SteppingManager::InvokeAtRestDoItProcs()
No AtRestDoIt process is active!
This happens when a user disables stochastic processes and a track stops.
There are surely other errors that are just printed like this.
As users rarely check the output file for such lines, this can easily go unnoticed. It should also be changed to call G4Exception(), as should all similar error reports.
Two points:
1. exit() and abort() are not the only issues here.
2. There should be a new G4Exception severity: TrackMustBeAborted
(there's no real need to abort the entire event).
Also, I forgot to mention that in my MPI code, G4Exception(...FatalException...) closes up in an MPI-aware manner.
Thanks for reporting this. Corrections for the relevant cases have been implemented in the development trunk. A severity state of the kind "TrackMustBeAborted" has not be provided in order to preserve the integrity of an event and avoid energy non-conservation issues... It may be considered, though. The idea of TrackMustBeAborted is that some applications work at the track level, not the event level (e.g. "vertex" has no meaning, an event starts with a beam track). Geant4 forces G4beamline to consider an initial track to be an event, but there really is no need or desire to combine its secondaries with the original track. All that matters in this application is where the tracks go. So if one track has a problem, it is HIGHLY desirable to continue tracking the others, even if they happened to be associated together in an event. An application that works at the event level could implement a Notify() that converts TrackMustBeAborted into EventMustBeAborted. Indeed the default Notify() could do this. |
Many Geant4 routines call abort() and exit(). This is a MAJOR problem when built for use with MPI, because having one dead process out of many has a high likelihood of hanging the entire job (thousands of processes on a supercomputer). Moreover, printing an error message and then calling abort() or exit() is ineffective, because a user cannot be expected to look at thousands of copies of stderr/stdout (and large MPI jobs usually omit them). Every one of these calls should be changed to call G4Exception(...FatalException...), and coding standards should be modified to prevent introducing new ones. Any sensible MPI job will arrange so such calls get logged appropriately and flagged to the user. Moreover, the MPI job can closeup properly when a FatalException is detected (rather than just letting some future MPI call hang forever waiting for the already-exited process). A direct call to abort() or exit() bypasses the MPI detection of failed processes. There is a rather ugly workaround: replace abort() and exit() with user routines that are MPI aware. The problem is that this cannot convey to the user the reason for the failure; G4Exception() does. Fortunately, no Geant4 routine calls _exit() -- that cannot be overridden by the user, and is needed by user code. Actually, this should apply to exit() as well. Here is a list of source files that contain 'abort(' or 'exit(': ./error_propagation/History ./error_propagation/src/G4ErrorMatrix.cc ./externals/clhep/src/NonRandomEngine.cc ./geometry/solids/BREPS/History ./global/History ./global/management/include/G4FPEDetection.hh ./global/management/src/G4Exception.cc ./interfaces/basic/src/G4UIQt.cc ./interfaces/GAG/src/G4UIGainServer.cc ./interfaces/History ./processes/electromagnetic/dna/utils/src/G4DNAMolecularReactionTable.cc ./processes/electromagnetic/highenergy/History ./processes/electromagnetic/utils/History ./processes/electromagnetic/utils/src/G4EnergyLossTables.cc ./processes/hadronic/models/abla/src/G4Abla.cc ./processes/hadronic/models/incl/src/G4Abla.cc ./processes/hadronic/models/incl/src/G4Incl.cc ./processes/hadronic/models/inclxx/incl_physics/include/G4INCLFPEDebug.hh ./processes/hadronic/models/inclxx/incl_physics/src/G4INCLCascade.cc ./processes/hadronic/models/inclxx/incl_physics/src/G4INCLDeltaDecayChannel.cc ./processes/hadronic/models/inclxx/incl_physics/src/G4INCLNucleus.cc ./processes/hadronic/models/inclxx/utils/include/G4INCLLogger.hh ./processes/hadronic/models/inclxx/utils/include/G4INCLParticleTable.hh ./processes/hadronic/models/inclxx/utils/src/G4INCLConfig.cc ./processes/hadronic/models/inclxx/utils/src/G4INCLStore.cc ./processes/hadronic/models/lll_fission/History ./processes/hadronic/models/neutron_hp/src/G4NeutronHPThermalScattering.cc ./processes/hadronic/models/radioactive_decay/History ./visualization/externals/gl2ps/src/gl2ps.cc ./visualization/externals/zlib/src/zutil.cc ./visualization/gMocren/src/G4GMocrenIO.cc ./visualization/History ./visualization/OpenGL/src/G4OpenGLXViewer.cc