Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Core file generation

Wu__Wentao
Beginner
2,913 Views
Hi!
I am using the operation system ofLinux ubuntu 2.6.32-36-generic and Intel Fortran Compiler ifort 12.1.0
Here is the question. when gcc or gfortran is employed to compile source file into .out program and when the segmentation fault occurs during the .out running, a core file will be generated in the working directory, with which gdb can locate the line where the error stemmed according to source files.
I have configured my system in bash with command
$ulimit -c unlimited
and compile my source code with
$ifort -O0 -debug -g core_test.f90 -o core_test.out
Runing the core_test.out, a expected segmentation fault occurs:
$ ./core_test.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
core_test.out 08049E24 Unknown Unknown Unknown
core_test.out 08049D54 Unknown Unknown Unknown
libc.so.6 00D9DBD6 Unknown Unknown Unknown
core_test.out 08049C61 Unknown Unknown Unknown
But the desired core file is not found!
Can Intel fortran compiler generate the core file? And how to do it?
Thanks for any help!
Best regards,
David
0 Kudos
1 Solution
pbkenned1
Employee
2,913 Views

OK, this has nothing to do with the flavor of Linux OS.The issue is that with your test case, the Fortran runtime is aborting the program before the core file can be generated. For a case like this, you need to set the environment variable f77_dump_flag=TRUE to return control to the program.

Notice that when you ran, you didn't get 'Aborted (core dumped)'. Set f77_dump_flag=TRUE, and rerun the program. I did the following with your example on Ubuntu 10.10 (Linux version 2.6.35-22-generic):

$ ifort -V

Intel Fortran Compiler XE for applications running on IA-32, Version 12.1.1.256 Build 20111011

$ ifort -g -c core_test.f90

$ ifort core_test.f90 -g -fpe0 -O0 -o core_test.x -traceback

$ export f77_dump_flag=TRUE

$ ./core_test.x

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

Image PC Routine Line Source

core_test.x 08049DAA MAIN__ 7 core_test.f90

core_test.x 08049D34 Unknown Unknown Unknown

libc.so.6 003CCCE7 Unknown Unknown Unknown

core_test.x 08049C41 Unknown Unknown Unknown

Aborted (core dumped)

I verified this generate the core file.

Patrick

View solution in original post

0 Kudos
5 Replies
pbkenned1
Employee
2,913 Views
Did you set your core file limit to something other than 0? Commonly it defaults to 0. You also need to be using idb from the 12.1.1 compilers to debug core files from the command line. And, make sure you compile with -g for symbols, and with -fpe0 to catch the exception. Here's how:

~> ifort -V

Intel Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.1.256 Build 20111011

~> cat DivZero.f90

program div_zero

real x,y,z

x=1.0

y=0.0

z=x/y

print *,'z = ',z

end program div_zero

~> ifort DivZero.f90 -g -c

~> ifort DivZero.f90 -g -fpe0 -o DivZero.x

~> ulimit -c unlimited

~> ./DivZero.x

forrtl: error (73): floating divide by zero

Image PC Routine Line Source

DivZero.x 0000000000402C53 Unknown Unknown Unknown

DivZero.x 0000000000402BEC Unknown Unknown Unknown

libc.so.6 00007F9ECEBC9BC6 Unknown Unknown Unknown

DivZero.x 0000000000402AE9 Unknown Unknown Unknown

Aborted (core dumped)

~> ls core

core

~> idbc DivZero.x core

Intel Debugger for applications running on Intel 64, Version 12.1, Build [76.896.14]

------------------

object file name: DivZero.x

core file name: core

[New Thread 7078 (LWP 7078 "")]

Reading symbols from /home/pbkenned/DivZero.x...done.

Program received signal SIGABRT

raise () in /lib64/libc-2.11.1.so

(idb) symbol-file DivZero.o

(idb) list

1 program div_zero

2 real x,y,z

3 x=1.0

4 y=0.0

5 z=x/y

6 print *,'z = ',z

7 end program div_zero

(idb) where

#0 0x00007f9ecebdd945 in raise () in /lib64/libc-2.11.1.so

#1 0x00007f9ecebdef21 in abort () in /lib64/libc-2.11.1.so

#2 0x0000000000403268 in for__signal_handler () in /home/pbkenned/DivZero.x

#3 0x00007f9ecef185d0 in __restore_rt () in /lib64/libpthread-2.11.1.so

#4 0x0000000000402c53 in div_zero () at /home/pbkenned/DivZero.f90:5

(idb)

Patrick Kennedy
Intel Developer Support

0 Kudos
Wu__Wentao
Beginner
2,913 Views
Thank you Patrick! I have repeated your procedure and obtained the core file.
However, my program still cannot generate it.
$ ulimit -c unlimited
$ ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 20
file size (blocks, -f) unlimited
pending signals (-i) 16382
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) unlimited
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
$ cat core_test.f90
program main
implicit none
integer :: i
integer, dimension(:), allocatable :: x
! allocate(x(5))
do i = 1, 5
x(i) = i
end do
stop
end program
$ ifort core_test.f90 -g -c
$ ifort core_test.f90 -g -fpe0 -O0 -o core_test.x
$ ./core_test.x
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
core_test.x 08049DAA Unknown Unknown Unknown
core_test.x 08049D34 Unknown Unknown Unknown
libc.so.6 00126BD6 Unknown Unknown Unknown
core_test.x 08049C41 Unknown Unknown Unknown
$ ls -al core
ls: cannot access core: No such file or directory
$ ls -al
total 492
drwxr-xr-x 2 davidwu davidwu 4096 2011-11-23 11:52 .
drwxr-xr-x 4 davidwu davidwu 4096 2011-11-23 11:45 ..
-rw-r--r-- 1 davidwu davidwu 150 2011-11-23 11:46 core_test.f90
-rw-r--r-- 1 davidwu davidwu 2136 2011-11-23 11:51 core_test.o
-rwxr-xr-x 1 davidwu davidwu 486687 2011-11-23 11:52 core_test.x
Did I miss something?
Best regards,
David
0 Kudos
pbkenned1
Employee
2,913 Views
Hello David,
No core file was created...very strange. I don't think you missed anything. You are using an earlier v12 ifort than I am, but I doubt this has anything to do with the compiler itself. Perhaps it is something about your version of Linux, ubuntu 2.6.32-36-generic. I see on different versions of Linux, the core file might have a different name, like core.1867, but you listed everything in the directory where you ran the executable, and there is no file matching core*. Let me look into this, and I'll get back to you.

Thanks,
Patrick
0 Kudos
pbkenned1
Employee
2,914 Views

OK, this has nothing to do with the flavor of Linux OS.The issue is that with your test case, the Fortran runtime is aborting the program before the core file can be generated. For a case like this, you need to set the environment variable f77_dump_flag=TRUE to return control to the program.

Notice that when you ran, you didn't get 'Aborted (core dumped)'. Set f77_dump_flag=TRUE, and rerun the program. I did the following with your example on Ubuntu 10.10 (Linux version 2.6.35-22-generic):

$ ifort -V

Intel Fortran Compiler XE for applications running on IA-32, Version 12.1.1.256 Build 20111011

$ ifort -g -c core_test.f90

$ ifort core_test.f90 -g -fpe0 -O0 -o core_test.x -traceback

$ export f77_dump_flag=TRUE

$ ./core_test.x

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

Image PC Routine Line Source

core_test.x 08049DAA MAIN__ 7 core_test.f90

core_test.x 08049D34 Unknown Unknown Unknown

libc.so.6 003CCCE7 Unknown Unknown Unknown

core_test.x 08049C41 Unknown Unknown Unknown

Aborted (core dumped)

I verified this generate the core file.

Patrick

0 Kudos
Wu__Wentao
Beginner
2,913 Views
Thank you very muchfor your compehensive analysis and elegent solution!
After export the f77_dump_flag environment variable, the core file was eventually generated!
0 Kudos
Reply