Created attachment 517 [details] gdb backtrace Calling G4Torus::DistanceToIn(p, v) with a large (norm ~ kInfinity) initial `p` vector may invoke G4JTPolynomialSolver::FindRoots to solve an equation where one of the coefficients is (floating-point) infinity. This causes an infinite loop when trying to "Chop the interval (0,x) until ff <= 0", as `ff` becomes NaN and the loop termination comparison never succeeds. I use Geant4.10.2, on Linux and an i5-5200U, built in the Release configuration, with gcc, and the '-ggdb3' flag. This happens very rarely -- I have an application (https://github.com/mstoeckl/gview) which produces unusual geometry queries (e.g., along rays close to perfectly tangent to solids, and starting very far away from the target), and have encountered infinite loops only twice out of ~10^5 such queries. A slight change to my own code avoids the bug entirely.
Thank you for reporting the problem. Normally the DistanceToIn(p,v) method in a solid with curved surfaces should have a check on how far is a point p from the solid. If the point is too far, then it should be moved closer to the surface. It looks that G4Torus::DistanceToIn(p,v) does not have such a check. We will investigate and improve the code if it is the case.
Created attachment 518 [details] Modified G4Torus.cc Could you try modified G4Torus.cc where missing check has been added. I believe that it should fix the problem.
A check "if point is too far" has been added into G4Torus::DistanceToIn(p,v).