Gmx energy giving infinite potential, gmx analyze gives normal values

GROMACS version: 2022.4-plumed_2.8.1-dev
GROMACS modification: No

Hello everyone,
I used gmx energy -f md.edr to extract potential, and some other data, and obtained unreasonably large averages for some of the quantities:

Last energy frame read 375047 time 3750470.000         

Statistics over 937617501 steps [ 0.0000 through 3750470.0000 ps ], 10 data sets
All statistics are over 9376176 points

Energy                      Average   Err.Est.       RMSD  Tot-Drift
-------------------------------------------------------------------------------
Angle                       63145.9         58     431.04   -281.358  (kJ/mol)
Proper Dih.                 -866685         17    268.573   -7.79246  (kJ/mol)
Potential                -2.45376e+30    2.5e+30        inf -2.11104e+30  (kJ/mol)
Kinetic En.                  367239          1    1080.63    5.92956  (kJ/mol)
Total Energy             -2.45376e+30    2.5e+30        inf -2.11104e+30  (kJ/mol)
Temperature                 299.578    0.00082   0.881532 0.00483695  (K)
Pres-XX                  -6.45462e+26    6.5e+26        inf -5.55565e+26  (bar)
Pres-YY                  -1.11853e+21    1.1e+21        inf -9.31533e+20  (bar)
Pres-ZZ                  -4.43904e+19    4.4e+19        inf -3.80858e+19  (bar)
#Surf*SurfTen            1.37214e+28    1.4e+28        inf 1.18104e+28  (bar nm)

Using python script or gmx analyze on energy.xvg file produced from this command gives adequate averages:

Read 10 sets of 375048 points, dt = 10

                                      std. dev.    relative deviation of
                       standard       ---------   cumulants from those of
set      average       deviation      sqrt(n-1)   a Gaussian distribition
                                                      cum. 3   cum. 4
SS1   6.314611e+04   4.308130e+02   7.034706e-01       0.170    0.269
SS2  -8.666846e+05   2.688622e+02   4.390226e-01       0.002    0.002
SS3  -4.056204e+06   9.326106e+04   1.522851e+02      64.452   4011.803
SS4   3.672377e+05   1.079467e+03   1.762651e+00       0.006    0.000
SS5  -3.688966e+06   9.327248e+04   1.523038e+02      64.428   4009.618
SS6   2.995767e+02   8.805824e-01   1.437895e-03       0.006    0.000
SS7  -5.755222e+00   1.031434e+03   1.684219e+00      -62.889   3923.191
SS8  -5.465815e+00   1.031642e+03   1.684559e+00      -62.903   3925.295
SS9  -6.994908e+00   1.030962e+03   1.683448e+00      -62.900   3926.153
SS10  -5.885941e+01   6.701908e+03   1.094348e+01       0.002    0.000

I noticed that this happens if some of the values exceed 1e7 in a time step (which probably is not great but very far from 1e30 given by gmx energy). I am not sure why I have such ‘jumps’ of potential for some frames (I did check topology and it seems correct).

I would like to understand if this averages are what to be expected and which averages I should trust : gmx energy or gmx analyze

I can provide the corresponding .edr file if needed.
Thank you for any information on this