Suprious FPEs on MacOSX in G4Tubs constructor

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 = '', 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 [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

Mike, FPE handlers on macOS are not reliable and don’t work. If you want to check your code with FPE_DEBUG, do it on Linux instead.

Sigh. Okay, thanks, Gabriele. That’s probably why it’s only me and a couple of the students who have been running into problems.

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