grimme-lab / xtb

Semiempirical Extended Tight-Binding Program Package
https://xtb-docs.readthedocs.io/
GNU Lesser General Public License v3.0
591 stars 148 forks source link

`Invalid free` when running cpcmx on methane, only for certain solvents #1115

Open TyBalduf opened 1 month ago

TyBalduf commented 1 month ago

Describe the bug CPCM-X calculations on methane with certain solvents crash just after finishing the CPCM-X post-SCF solvation evaluation SCF iterations.

 -------------------------------------------------
  |      CPCM-X post-SCF solvation evaluation       |
 -------------------------------------------------

 iter      E             dE          RMSdq      gap      omega  full diag
   1     -4.2264158 -0.422642E+01  0.137E-02   15.60       0.0  T
   2     -4.2264164 -0.561220E-06  0.400E-04   15.60     111.9  T
   3     -4.2264164 -0.346902E-09  0.767E-05   15.60     583.0  T
     SCC iter.                  ...        0 min,  0.000 sec
     gradient                   ...        0 min,  0.000 sec
free(): invalid next size (fast)

To Reproduce Run a xtb meth.sdf --cpcmx <solvent> with seemingly any other solvent, but water. I have at least seen this for acetonitrile, toluene, and benzene.

(Had to upload as txt) meth_out.txt meth_sdf.txt

Expected behaviour Should run successfully consistently.

Additional context Seems to be related to this other issue https://github.com/grimme-lab/xtb/issues/1049. But in their case, they compiled with gfortran/gcc, while I used ifort/gcc on Linux and ifort/msvc on Windows.

Interestingly, the failure is somewhat sporadic and even subtle changes to the calculation can make it go away. For example, if I use -cpcmx in my submission, the output file warns about using a single dash, but the calculation actually proceeds to completion: single_dash_meth_out.txt

On Windows, its even more sporadic, where if I run it repeatedly from the restart file, it will sometimes fail and sometimes not.

It doesn't seem to be related to the number of threads; while the attached outputs were run without OMP_NUM_THREADS or MKL_NUM_THREADS set, I reran these multiple times with both of these environment variables set to 1 and this did not resolve the failures.