Problem 2452 - SIGFPE issue in G4VRestDiscreteProcess
Summary: SIGFPE issue in G4VRestDiscreteProcess
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes (show other problems)
Version: 10.7
Hardware: All All
: P4 minor
Assignee: Vladimir.Ivantchenko
URL:
Depends on:
Blocks:
 
Reported: 2021-12-07 17:24 CET by mis2
Modified: 2022-11-04 12:57 CET (History)
1 user (show)

See Also:


Attachments
Patched version of G4VRestDiscreteProcess.cc (5.91 KB, text/x-c++src)
2021-12-07 17:24 CET, mis2
Details

Note You need to log in before you can comment on or make changes to this problem.
Description mis2 2021-12-07 17:24:45 CET
Created attachment 742 [details]
Patched version of G4VRestDiscreteProcess.cc

If I compile geant4.10.07-p03 with floating point exceptions enabled the code throws a SIGFPE inside the G4VRestDiscreteProcess:AtRestGetPhysicalInteractionLength method. 

The SIGFPE is caused when simulating particles (such as electrons) where the variable currentInteractionLength=DBL_MAX. 

The line (return theNumberOfInteractionLengthLeft* currentInteractionLength) causes an overflow if theNumberOfInteractionLengthLeft > 1 which results in the SIGFPE.

To fix this I added a check on the currentInteractionLength and theNumberOfInteractionLengthLeft variables to see if their product will cause an overflow. In the case where they do overflow the function returns DBL_MAX, otherwise the calculation proceeds as normal.

I have attached a patched version of the code to this message
Comment 1 Vladimir.Ivantchenko 2021-12-15 20:23:25 CET
Hello,

Thanks for the report. Before trying to introduce a fix it is necessary to know what Physics List is used. Electrons are main part of any simulation. Why in this application such crash is seen but not in any other?

VI
Comment 2 mis2 2021-12-15 23:43:56 CET
Hi,
Comment 3 mis2 2021-12-15 23:58:40 CET
Hi,

   We use a custom physics list for electron simulations the processes we use are G4eMultipleScattering, G4eIonisation and G4eBremsstrahlung 

Thanks,
Mark
Comment 4 Vladimir.Ivantchenko 2022-01-28 08:38:41 CET
Hello,

I have an assumption that in your custom Physics List you register ionisation or bremsstrahlung AtRest. These processes cannot work at rest.

Two alternative suggesting:
   - review your custom physics configuration and disable all processes at rest, except positron annihilation;
   - use Physics Lists from Geant4 distribution.

VI
Comment 5 Vladimir.Ivantchenko 2022-11-04 12:57:34 CET
hello,

the bug is fixed and the fix will be available with the next public Geant4 release in December. It may be back-ported to previous releases if extra patches will be done.

VI