Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ESP SegFaults with GCC #728

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

foxtran
Copy link
Contributor

@foxtran foxtran commented Nov 23, 2022

I compiled xtb 6.5.1 with cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release (GCC 8.5.0 was found, I did not notice that xtb was compiled with OpenMP support according to make VERBOSE=1 output)

And, then, I tried to compute ESP. Unfortunately, I got some SegFaults when runs were. In Debug mode, I got Fortran runtime errors since read_xyz from mctc_io returns allocated lattice with size 0 and pbc with size 1. I rewrote molecule.f90 a little bit to avoid these issues.

Then, in esp.f, I again got a Fortran runtime error:

At line 127 of file <PATH>/xtb/src/esp.f
Fortran runtime error: Index '706' of dimension 1 of array 'espe' above upper bound of 705

It was due to a part of the routine for checking approximate computing ESP time had espe(i) where i exceeds np after do i=1,np cycle. So, I just put the index to a reasonable value - 1.

Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in src/type/molecule.f90 seem unrelated to the ESP fix. Can you provide a reproducer which fails with the previous setup?

@foxtran
Copy link
Contributor Author

foxtran commented Dec 17, 2022

The changes in src/type/molecule.f90 seem unrelated to the ESP fix. Can you provide a reproducer which fails with the previous setup?

I do not remember exactly on which machine I tested this code, but...

  1. git clone git@github.com:grimme-lab/xtb.git
  2. cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug
-- The C compiler identification is GNU 11.3.1
-- The Fortran compiler identification is GNU 11.3.1
  1. cd build
  2. make -j $(nproc)
  3. ./xtb --esp BD.xyz
    fails with
At line 211 of file /dev/shm/xtb/src/type/molecule.f90
Fortran runtime error: Array bound mismatch for dimension 1 of array 'mol' (3/0)

Error termination. Backtrace:
#0  0x7ff0f4e237c2 in ???
#1  0x7ff0f4e24289 in ???
#2  0x7ff0f4e2489a in ???
#3  0x763454 in __xtb_type_molecule_MOD_initmolecule
        at /dev/shm/xtb/src/type/molecule.f90:211
#4  0x75e068 in __xtb_type_molecule_MOD_structure_to_molecule
        at /dev/shm/xtb/src/type/molecule.f90:382
#5  0x580857 in __xtb_io_reader_MOD_readmolecule
        at /dev/shm/xtb/src/io/reader.f90:95
#6  0x41f772 in __xtb_prog_main_MOD_xtbmain
        at /dev/shm/xtb/src/prog/main.F90:335
#7  0x42bf22 in xtb_prog_primary
        at /dev/shm/xtb/src/prog/primary.f90:57
#8  0x42bfb9 in main
        at /dev/shm/xtb/src/prog/primary.f90:20

Under gdb:

$ gdb --args ./xtb --esp BD.xyz
(gdb) b molecule.f90:211
Breakpoint 1, xtb_type_molecule::initmolecule (mol=..., at=..., sym=<incomplete type>, xyz=..., chrg=0, uhf=0, lattice=..., pbc=..., _sym=4) at /dev/shm/xtb/src/type/molecule.f90:211
211           mol%lattice = lattice
(gdb) p lattice
$1 = ()
(gdb) p size(lattice)
$2 = 0
(gdb) p size(pbc)
$3 = 1

BD.xyz is available here: https://gist.github.com/foxtran/2e56ea6577bebf055967416d572675c9

So, I fixed molecule.f90 just for continuing to debug ESP

@foxtran
Copy link
Contributor Author

foxtran commented Jan 30, 2023

@awvwgk, ping?

…ndex of array

Signed-off-by: Igor S. Gerasimov <i.s.ger@ya.ru>
Signed-off-by: Igor S. Gerasimov <i.s.ger@ya.ru>
Signed-off-by: Igor S. Gerasimov <i.s.ger@ya.ru>
@foxtran
Copy link
Contributor Author

foxtran commented Dec 4, 2023

The changes in src/type/molecule.f90 seem unrelated to the ESP fix. Can you provide a reproducer which fails with the previous setup?

Was fixed in #774 and in #907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants