?HSEIN functions could hang if there is a NaN on input in the matrix H and eigenvalues in W much larger than SMLNUMThe hanging happens in loop 70 and, since the NaN causes the value of HNORM to be also NaN, the value of EPS3 is set to SMLNUM at lines 402-405. If eigenvalues are large enough the operation at line 417 WK = WK + EPS3 doesn't alter the eigenvalue since WK .EQ. WK + EPS3 just because EPS3 is below significant digits for WK. And the loop infinitely iterates over the same value of WK.

As I see the fix is simple given we have the new norm function with NaN checkers from LAPACK 3.4.2. Just check the received HNORM value for NaN and report error for the input parameter H. It could be something like this:

I have added a check for NaN in the HNORM in revision 1350 of the LAPACK svn repository. The routine now will exit with INFO=-6, but no call to XERBLA, if a NaN is detected in the norm of H. Hopefully this will fix the problem.

I think you also need to take care about positive & negative infinity.The code example below would loop forever not only for NaNbut also for positive infinity.So recent lapack changes (NaN checking) is not sufficient to avoid infinite loops.The best way is to have explicit integer limit for such loops.