Building application with -openmp but no OpenMP pragmas causes segmentation fault


When building an application without the -openmp option, the application runs just fine.  When the same application is built with the -openmp option it segmentation faults.  No changes were made to the application's source code and the application contains no OpenMP pragmas.


Applications built with the Intel® Fortran compiler on all operating systems.

Root Cause

The -openmp option also turns on the -auto option which causes arrays to move from the heap to the stack.  If your application contains many or large arrays this can cause a segmentation fault because the application has exceeded the size of the stack.  The -auto option is turned on despite the absence of OpenMP pragmas to maintain thread safety.  The compiler does not know if the routines in the source file will be called from other routines containing OpenMP pragmas.


Increase the stsack size for your application.  Setting the application stack size varies by operating system and is discussed in a separate article on increasing stack size.

Another workaround is to use the -heap-arrays option, but care must be taken when using this option because it does not necessarily make the application thread safe.  If you can guarantee that the arrays in the source file not be used by any threads in your application, you can use this option instead of increasing the stack size.