I have FPE’s enabled in my Geant4 and application build (G4FPE_DEBUG
), which are very helpful when we have runtime parameter configuration mistakes. Unfortunately, I’m now occasionally getting FPEs (divide by zero) from the default geometry construction, which don’t make any sense to me. Here’s an example, captured in the debugger:
Process 79614 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_ARITHMETIC (code=EXC_I386_SSEEXTERR, subcode=0x1d25)
frame #0: 0x0000000104e3ad82 libG4geometry.dylib`G4Tubs::G4Tubs(this=0x000000010a6db720, pName=<unavailable>, pRMin=0, pRMax=609.44999999999982, pDz=<unavailable>, pSPhi=0, pDPhi=6.2831853071795862) at G4Tubs.cc:64:16 [opt]
61 G4double pSPhi, G4double pDPhi )
62 : G4CSGSolid(pName), fRMin(pRMin), fRMax(pRMax), fDz(pDz),
63 fSPhi(0), fDPhi(0),
-> 64 fInvRmax( pRMax > 0.0 ? 1.0/pRMax : 0.0 ),
65 fInvRmin( pRMin > 0.0 ? 1.0/pRMin : 0.0 )
66 {
67 kRadTolerance = G4GeometryTolerance::GetInstance()->GetRadialTolerance();
The error happens at line 64, in the computation 1.0/pRMax
. But you can see from the constructor arguments that pRMax = 609.45, which is certainly not zero. Printing pRMax
directly confirms that value.
We have apparently been getting errors like this in our simulation on different platforms, with different G4 versions, for a while. I can rebuild and run without FPE trapping, but that seems like the wrong approach to solving this.
Has anyone else seen FPEs coming from within the G4 geometry code like this?
Geant4 Version: 10.07.p04 (yes, I know it’s old)
Operating System: MacOSX 10.15.7 (Catalina)
Compiler/Version: LLVM Apple Clang 12.0.0
CMake Version: CMake 3.15.2