Problem 1169

Summary: G4EventManager::DoProcessing() does not clear abortRequested properly
Product: Geant4 Reporter: Tom Roberts <tjrob>
Component: eventAssignee: asai
Status: RESOLVED FIXED    
Severity: normal    
Priority: P5    
Version: 9.4   
Hardware: All   
OS: All   

Description Tom Roberts 2011-02-04 00:53:40 CET
G4EventManager::DoProcessing() clears the abortRequested flag at the end of the routine, not at the beginning. It should be cleared at the beginning. An alternate fix would be to provide a function G4EventManager::ClearAbortFlag().

This is important in my private version of G4RunManager, in which the event loop has a setjmp to permit a SIGALRM to jump back to start a new event, aborting the one that entered an infinite loop. With the current code, this also aborts the following event, because the G4EventManager remembers the previous event's abortRequested flag, and offers me no way to clear it.

Replies to obvious comments:
Yes, longjmp from a signal handler is risky, but it is OK when interrupting a pure code loop, such as this. In my code it can only happen if my UserSteppingAction() has not been called for >10 seconds, which implies there is an infinite loop somewhere in the tracking code (it is typically called thousands of times per second).

Yes, it is better to fix the looping code rather than relying on an alarm signal. That is not always feasible in a program with >2 million lines of code from libraries written by others. The loop that is plaguing my users happens only once per a few million events.
Comment 1 asai 2011-02-10 22:45:42 CET
Thank you for the report. I will look into it.
Kind regards,
Makoto
Comment 2 asai 2011-02-11 01:05:29 CET
Thank you once again for your report. I added one more reset of abortRequested flag at the top of G4EventManager::DoProcessing() method. This modification should be included in the next (patch) release.

Kind regards,
Makoto