crest-lab / crest

CREST - A program for the automated exploration of low-energy molecular chemical space.
https://crest-lab.github.io/crest-docs/
GNU Lesser General Public License v3.0
198 stars 42 forks source link

Possibly uninitialized variable #249

Closed goxeq closed 8 months ago

goxeq commented 8 months ago

While running crest I got the following error (I compiled the current version with gcc):

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x14ae0605c70f in ???
#1  0x555e5a46a331 in write_cts_nci_
    at crest/src/constraining.f90:526
#2  0x555e5a453ee9 in setmdrun2_
    at crest/src/confscript2_misc.f90:777
#3  0x555e5a5e86a1 in trialmd_
    at crest/src/trialmd.f90:120
#4  0x555e5a44c1b0 in confscript2i_
    at crest/src/confscript2_main.f90:72
#5  0x555e5a6151c5 in crest
    at crest/src/crest_main.f90:249
#6  0x555e5a615876 in main
    at crest/src/crest_main.f90:25

Since I did not specify NCI mode, it was quite strange that it was in a function write_cts_NCI(ich,cts) in a place where it could never get if cts%NCI was false. So - I looked at where the variable is referenced in code and could not find any place where it is initalized to .false. which would be logical.

src/classes.f90
89:      logical :: NCI
src/constraining.f90
524:  if (cts%NCI) then
545:  if (cts%NCI) then
src/ncigeo.f90
50:  env%cts%NCI = .true.
src/qcg/solvtool.f90
 964:   env%cts%NCI = .true.  !Activating to have wall pot. written in coord file for xtb
1123:      if (env%cts%NCI) then
1287:   env%cts%NCI = .false.  !Dactivating the wall pot.

Threfore, I believe that line 89 should be logical :: NCI = .false. After that change it no longer crashes for me.

pprcht commented 8 months ago

As of #250 this is fixed as suggested