Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-13-2014, 06:25 PM   #1
Registered: Mar 2014
Posts: 444

Rep: Reputation: Disabled
Segmentation fault (core dumped)

What does it mean in GFortran? I get it when I run a command ./a.out. Segmentation fault (core dumped) Thanks, - A.

Last edited by AlexBB; 12-13-2014 at 06:27 PM.
Old 12-13-2014, 06:31 PM   #2
Ser Olmy
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 2,470

Rep: Reputation: Disabled
Your program contains a serious bug/error, and was terminated by the operating system.

Typically, the program would have tried to access an invalid memory location. It's impossible to say what the problem might be without at least seeing the source code.
Old 12-13-2014, 08:41 PM   #3
Registered: Jul 2009
Location: Murfreesboro TN (United States)
Distribution: Ubuntu 16.04.3 and 14.04.5, Debian 8.9 and 9.2
Posts: 131
Blog Entries: 36

Rep: Reputation: 26
I have had segmentation faults several times from Fortran codes. The sorts of things I look for are:

undefined variables (I usually use 'IMPLICIT NONE' to eliminate this sort of thing)

variable type or length mismatch between variables in a calling argument list and the subprogram argument list

an array index way out of bounds (turn on the array bounds checker in the compiler)
Old 12-15-2014, 02:30 PM   #4
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,844
Blog Entries: 12

Rep: Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010Reputation: 2010
Well you got a core file, which if you have a debugger, you can view the backtrace or see information about program variables and such at the time that the segmentation fault occurred. You can use GDB for this. You should have compiled your program with the -g flag, if you haven't, then re-compile with the -g flag, re-run and if/when you encounter the segmentation fault and get a core file you can then load that up using GDB.
gdb <executable-file> core
I haven't done this for FORTRAN but I'd imagine that you'd have a backtrace or some other capability to give you a report on what happened. If all else fails, create debug in various points of the code to document program progress so you can better zero in on where you hit the segfault. Or just run from within the debugger and when it hits the fault, you should be able to determine where in your program you were before hitting the fault.
Old 12-16-2014, 08:23 AM   #5
Registered: Jul 2009
Location: Murfreesboro TN (United States)
Distribution: Ubuntu 16.04.3 and 14.04.5, Debian 8.9 and 9.2
Posts: 131
Blog Entries: 36

Rep: Reputation: 26
locate the source of the segmentation fault with a binary search

Another way to try to locate the source of the segmentation fault is with a sort of binary search in the source code by inserting output statements (e.g., WRITE(*,*)'message'). The idea is to bracket the fault location in the source code by what you see on the screen after execution. One problem with this approach is that once the segmentation fault has occurred, execution may stop without having "flushed" all of the print buffers, which is to say, that the output of some successfully executed WRITE statements may not reach the screen. To flush the buffers, use a STOP statement after the most recently inserted WRITE statement (removing the STOP when you insert the next WRITE and STOP). This type of binary search is a crude alternative if the debugger doesn't tell you what you want to know, but it might reduce the amount of code you will have to scan visually to find your error.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault (core dumped) mohammad taqy bayat Linux - Newbie 3 08-25-2014 03:10 AM
Segmentation fault (Core dumped) ramshank Linux - Newbie 4 04-24-2014 03:35 AM
segmentation fault (core dumped) - what??? Micro420 Programming 6 12-07-2006 02:03 AM
Segmentation fault (core dumped) plisken Linux - General 8 09-17-2003 04:32 AM
Segmentation fault (core dumped) hasanaydin Linux - General 0 03-27-2002 08:47 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration