Segmentation faults

From Geos-chem
Revision as of 20:24, 14 June 2019 by Bmy (Talk | contribs) (Overview)

Jump to: navigation, search

Previous | Next | Guide to GEOS-Chem error messages | Getting Started with GEOS-Chem | GEOS-Chem Main Page

  1. Compile-time warnings and errors
  2. Run-time crashes and abnormal exits
  3. Segmentation faults
  4. Other less-common errors


Overview

NOTE: on this page we shall use the Intel Fortran Compiler error messages. You may get a slightly different error message if you are using a different compiler (such as GNU Fortran).

If your simulation dies with a segmentation fault error, this means that GEOS-Chem tried to access an invalid memory location. A segmentation fault error message looks similar to this:

forrtl: severe (174): SIGSEGV, segmentation fault occurred

but may differ depending on the compiler version you are using. Segmentation faults can be due to several causes, as shown in the following sections.

Look at the traceback error stack to find where the error happened

When GEOS-Chem dies with an error, it will print out an error stack. This is a list of routines that were called when the error occurred and the line at which the error occurred.

An error stack is included below:

forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source
libintlc.so.5      00002ACA46B91961  Unknown               Unknown  Unknown
libintlc.so.5      00002ACA46B900B7  Unknown               Unknown  Unknown
libnetcdff.so.5    00002ACA4473D682  Unknown               Unknown  Unknown
libnetcdff.so.5    00002ACA4473D4D6  Unknown               Unknown  Unknown
libnetcdff.so.5    00002ACA4471DD4C  Unknown               Unknown  Unknown
libnetcdff.so.5    00002ACA44721DB8  Unknown               Unknown  Unknown
libpthread.so.0    00000031A0A0F710  Unknown               Unknown  Unknown
geos.mp            000000000175FF79  hco_interface_mod         341  hco_interface_mod.F90
geos.mp            00000000005F1F47  carbon_mod_mp_emi        5490  carbon_mod.F
geos.mp            00000000016EAF33  emissions_mod_mp_         206  emissions_mod.F90
geos.mp            00000000010BB119  MAIN__                   1383  main.F
geos.mp            000000000040370E  Unknown               Unknown  Unknown
libc.so.6          00000031A061ED5D  Unknown               Unknown  Unknown
geos.mp            0000000000403619  Unknown               Unknown  Unknown

The top line with a valid routine and line number printed is the location of the error. In this case, there is an issue in hco_interface_mod.F at line 341. You may also choose to step back through the routines to determine what went wrong. Again, in this case, the problematic routine in hco_interface_mod.F90 was called from carbon_mod.F (line 5490), etc. It may be useful to recompile and rerun GEOS-Chem with additional debug options turned on (e.g. BOUNDS=yes, FPE-yes) to determine the cause of the error. For more information, see our GEOS-Chem coding and debugging wiki page.

Array-out-of-bounds error

Most often, a segmentation fault indicates an array out-of-bounds condition. To find out more information about where this error is occurring, recompile GEOS-Chem with the following Makefile options:

make realclean
make BOUNDS=yes TRACEBACK=yes

The BOUNDS=yes option will turn on Array Out-of-Bounds error checking. The TRACEBACK=yes option will print out the Error Stack, as described above. These options will provide more detailed error output.

After recompiling, you should receive an error message such as:

forrtl: severe (408): fort: (3): Subscript #1 of the array PBL_THICK has value -1000000 which is less than the lower bound of 1

This tells you that there is a problem with a certain array. Use the Unix grep command to search for all instances of this array in the GEOS-Chem source code:

grep -i PBL_THICK *.f*

and search for the problem.

NOTE: In the above example, we manually forced an out-of-bounds error with this line of code:

        !### FORCE OOB error for testing
        PBL_THICK(-1000000,J)   = BLTHIK

Removing this line will fix the error.

--Bob Yantosca (talk) 22:19, 6 January 2017 (UTC)

Invalid memory access

A segmentation fault can also happen if GEOS-Chem makes an reference to a memory location that is invalid. You may see an error message such as this:

severe (174): SIGSEGV, segmentation fault occurred
This message indicates that the program attempted an invalid memory reference.
Check the program for possible errors.

This can happen if you are trying to read data from a file into an array, but the array is too small to hold all of the data. You can use a debugger (such as Totalview or IDB) to try to diagnose the situation. You may receive an error message from the debugger similar to this one:

 Thread received signal SEGV
 stopped at [<opaque> for_read_seq_xmit(...) 0x40000000006b6500] 
 
 Information:  An <opaque> type was presented during execution of 
 the previous command.  For complete type information on this symbol,
 recompilation of the program will be necessary.  Consult the compiler
 man pages for details on producing full symbol table information using   
 the '-g' (and '-gall' for cxx) flags.

Usually, increasing the size of the array (i.e. until it is large enough to contain all of the data) will fix this problem.

--Bob Y. 15:57, 22 June 2012 (EDT)

Stack overflow

Finally, a segmentation fault can happen if GEOS-Chem uses up all of the available stack memory on your system. The stack memory is a special part of the memory where short-term variables get stored.

The compiler will typically place into the stack memory all local temporary variables, such as:

  • variables that are local to a given subroutine
  • variables that are NOT located within a COMMON block
  • variables that are NOT declared with the SAVE attribute
  • variables that are NOT declared as an ALLOCATABLE array
  • variables that are NOT declared as a POINTER variable or array

Therefore, it is important to make sure that your computational environment is set up to use the maximum amount of stack memory. You can do this by placing the following line in your .cshrc file:

limit stacksize unlimited

or .bashrc file:

 ulimit -s unlimited

If you encounter a SIGSEGV(174) message due to a stacksize memory error, you may see the following error text:

severe (174): SIGSEGV, possible program stack overflow occurred
Program requirements exceed current stacksize resource limit.

--Bob Y. 15:57, 22 June 2012 (EDT)

forrtl: error (76): IOT trap signal

Xun Jiang wrote:

We met the following error message
   forrtl: severe (174): SIGSEGV, segmentation fault occurred

   Stack trace terminated abnormally.
   forrtl: error (76): IOT trap signal

   Note: The error appears after
   - RDSOIL: Reading
   Data/GEOS_2x2.5/soil_NOx_200203/climatprep2x25.dat
   ### MAIN: a DAILY DATA
I have the following lines in .cshrc
   setenv KMP_STACKSIZE 329033024
   limit cputime     unlimited
   limit datasize    unlimited
   limit stacksize   unlimited
   limit filesize    unlimited
   limit memoryuse   unlimited
   limit descriptors unlimited
However, it still doesn't work. Any suggestion is really appreciated.

Bob Yantosca replied:

I found this internet post which has an explanation:
   Cause: 
   The stack size for child threads are overflowing.  The main stack size for the program 
   is changed by the ulimit command (in Bash shell) or limit command (in C shell). 
   However this environment variable does not set the size for the child thread stack size. 
   Thus the child thread stack overflow.

   Solution:
   Set the environment variables to increase the child thread stack size.

   #for intel, using bash shell
   export KMP_STACKSIZE=500000000

   # for intel, using csh or tcsh shell
   setenv KMP_STACKSIZE 500000000
For more information, please see our wiki post on Resetting the stack size for Linux.

--Bob Y. 11:20, 26 June 2012 (EDT)

Segmentation fault encountered after TPCORE initialization

You may encounter a segmentation fault right after the following text is printed.

NASA-GSFC Tracer Transport Module successfully initialized

This error usually occurs when:

  1. You are running GEOS-Chem at sufficiently fine resolution, such as 2° x 2.5° or finer. (Many users have reported that this error does not occur at 4° x 5° resolution.)
  2. You are using a large number of advected tracers.
  3. Both #1 and #2

If you are using the Intel Fortran Compiler, the cause of this error can likely be traced to a known issue with the the glibc library. This will cause GEOS-Chem to think that it has used up all of the available memory, when in fact there is plenty of memory still available. However, you may also encounter this same error even if you have compiled GEOS-Chem with a different compiler.

You can usually correct this error by manually telling your system to use the maximum amount of stack memory when running GEOS-Chem. For detailed instructions, please see the following links:

  1. Setting stacksize for the Intel Fortran Compiler (aka "IFORT")
  2. Setting stacksize for the PGI Compiler
  3. Setting stacksize for the Sun Studio compiler

--Bob Y. 16:07, 14 December 2010 (EST)


Previous | Next | Guide to GEOS-Chem error messages | Getting Started with GEOS-Chem | GEOS-Chem Main Page