Apr 9, 2011

How to debug LAMMPS' run

When error "Segmentation Fault" pops up, we need to debug the run because many reasons can cause the error.


To find the location of the segmentation fault, you can just run lammps with the help of a debugger, e.g. gdb.

gdb  /path/lmp_openmpi

then on the gdb prompt you type:

run -in filename.in

and then wait for the segmentation fault.  When it happens, you can type:

where

and you get a stack trace and that will indicate the location of where the segmentation fault happens.




The alternative to this is to generate a core dump:

first type: ulimit -c unlimited

then run lmp_openmpi as usual. (lmp_openmpi -in filename.in)
after it crashed, you should see a file core.###. again, you can use gdb to investigate:

gdb /path/lmp_openmpi  /path/core.###

and then:

where

and you get a stack trace again, telling you the location (function name) of the problem.
and then you double check with the current version of lammps.



2 comments:

  1. Hey, thanks for this, very helpful!

    ReplyDelete
  2. Thank you for writing this down, it just saved me a lot of work!

    ReplyDelete