RMGDFT / rmgdft

RMG is an Open Source code for electronic structure calculations and modeling of materials and molecules. It is based on density functional theory and uses a real space basis and pseudopotentials.
GNU General Public License v2.0
47 stars 11 forks source link

Crash on rmg startup #50

Closed prckent closed 4 years ago

prckent commented 4 years ago

I am getting a memory free error and crash when e.g. running the diamond8 example. Potentially this could be a compile/link configuration isssue on my end. Type mismatch?

Development version from a few days ago. Intel 2019.1 compilers, MKL, C++ library from gcc 7.3.0

[pk7@oxygen diamond8]$ ../../build/rmg-cpu input
RMG running with 1 MPI procs per host.
Running with 24 Open MP threads.
Running with 24 RMG threads.

               * * * * * * * * * *
               *    R   M   G    *
               * * * * * * * * * *

 -- A Real Space Multigrid Electronic structure code --
 --      More information at www.rmgdft.org          --
*** Error in `../../build/rmg-cpu': free(): invalid next size (fast): 0x0000000010f92c00 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x816b9)[0x7fd860f556b9]
../../build/rmg-cpu(_ZN2PwC1ER8BaseGridR7Latticeib+0xcc8)[0x25058c8]
../../build/rmg-cpu(_Z12FftInitPlansv+0x91)[0x25088e1]
../../build/rmg-cpu(_Z4InitISt7complexIdEEvPdS2_S2_S2_S2_S2_S2_PP6KpointIT_E+0x24b)[0x80d68b]
../../build/rmg-cpu(_Z10initializeiPPc+0x40a)[0x598e2a]
../../build/rmg-cpu(main+0x4a9)[0x598089]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fd860ef6545]
../../build/rmg-cpu[0x597b29]
elbriggs commented 4 years ago

I just checked the latest commit and it runs correctly on a couple of platforms with gcc so it could be something specific to the Intel compiler. Could you do a debug build and see the exact line where the error is occurring? I'll also see about getting a local machine setup with the Intel compilers so that we can test that on a regular basis.

prckent commented 4 years ago

Thanks. I'll script my compilations here for reproducibility and also try the debug builds. Please can you add the debug build instructions to https://github.com/RMGDFT/rmgdft/wiki/Building-RMG ?

I assume that there is some incompatibility on my machine.

WenchangLu commented 4 years ago

can you try to change Misc/Pw.cpp, lines 190, 191 delete [ ] out; delete [ ] in; to fftw_free(out); fftw_free(in);

prckent commented 4 years ago

@WenchangLu Seems to work! I have run diamond8 and C60 successfully now.

prckent commented 4 years ago

@WenchangLu are you going to merge this change?

jcklasseter commented 4 years ago

I would greatly appreciate developer comments on the recommended way to debug but @prckent If it helps anyone, I was able to get some debug working on my test Ubuntu 18.04 VM by commenting the release option and uncommenting the debug option in the CMakeLists.txt, then the normal cmake .. from the clean build directory, then make

I ran the program with mpirun -np 1 xterm -e gdb /home/jack/rmgdft/build2/rmg-cpu

Which pops up a new gdb in xterm instance, where I could insert a break at main with something like b main and then start with run <rmgInFile>

Apologies if this is redundant, however

prckent commented 4 years ago

Thanks @jcklasseter . From my experience with other projects, what you suggest should work and is typical. I haven't tried with rmgdft yet, but changing CMAKE_BUILD_TYPE is the standard way of doing this in cmake projects. Ideally the CMakeLists.txt would check for input options and not override them, allowing for "cmake -DCMAKE_BUILD_TYPE=Debug .." and other options. e.g. Similar to https://github.com/QMCPACK/qmcpack/blob/develop/CMakeLists.txt#L129

elbriggs commented 4 years ago

Latest commit should let cmake -DCMAKE_BUILD_TYPE=Debug work reliably. As for general debug techniques @jcklasseter what you suggested is what I often do. If you are trying to debug anything other than a small example or if you are trying to debug a parallelization issue it becomes cumbersome very quickly though the use of gdb command files (-x option) can streamline the process

elbriggs commented 4 years ago

I went ahead and merged the change.