CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Segmentation fault

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By juliom
  • 2 Post By naffrancois

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 27, 2017, 10:28
Default Segmentation fault
  #1
New Member
 
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9
KaranG is on a distinguished road
I am running an open source CFD code called as COULWAVE.

While executing the code sometimes the error comes is

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

I am unable to understand the conditions in which the error comes. Because running the same program again and again sometimes the error disappears. Sometimes the program which was executed before with a definite set of parameters gives the error again.

Also, I could understand one thing that whenever the numerical model becomes unstable in the first time step due to some change in parameters, it gives this error. Is it true.
KaranG is offline   Reply With Quote

Old   July 27, 2017, 11:21
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Have you compiled it using Fortran compiler and if yes, have you used the check bound options?
FMDenaro is offline   Reply With Quote

Old   July 28, 2017, 02:38
Default
  #3
New Member
 
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9
KaranG is on a distinguished road
Firstly I want to clarify that I have a set of interlinked files in the open source code in fortran and I use it in Ubuntu. These set of files are compiled with the help of makefile provided in the code and it results in formation of an executable. That executable is run separtely for the given set of parameters and when after filling the parameters in the user interface of the executable it is run then this error is coming.

Also, the same file with specific set of parameters which were getting executed 2 days back without any difficulty are giving this same error when I am executing it now. Could this be the problem of the Operation system. Has the OS become corrupt. While there are some files which still get executed without this error still now.

Please help.

Also, I am sending the contents of the makefile in this reply as below:


# Start of the makefile
# Defining variables
mpicomp = mpif90
switch = -O3 -Waliasing -Wampersand -Wsurprising -Wintrinsics-std -Wintrinsic-shadow -Wline-truncation -Wconversion -Wcharacter-truncation -Wunderflow

# Makefile
pCOULWAVE_gfort.out:
$(mpicomp) $(switch) -c ./mainvar_module.f
$(mpicomp) $(switch) -c ./FV_var_module.f
$(mpicomp) $(switch) ./*.f* -o pCOULWAVE_gfort.out
clean:
rm *.o
rm *.mod
rm *.out
KaranG is offline   Reply With Quote

Old   July 28, 2017, 03:26
Default
  #4
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
I strongly suggest to debug your code without optimizations of any type and supplying the options for the check bounds array.
FMDenaro is offline   Reply With Quote

Old   July 28, 2017, 04:46
Default
  #5
New Member
 
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9
KaranG is on a distinguished road
Thanks for reply. I wish to know what do you mean by optimization types. Where do I need to provide check bounds array, is it in make file. Can you specify what is the check bounds array.

Also I want to ask that could this error be also connected to problem in Operating systems?
KaranG is offline   Reply With Quote

Old   July 28, 2017, 05:02
Default
  #6
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
"Check bounds" means You need first to assess that there is no access to array index out of the defined limits. That would violate some area of the memory. You have to substitute the "switch" options.
FMDenaro is offline   Reply With Quote

Old   July 28, 2017, 05:15
Default
  #7
New Member
 
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9
KaranG is on a distinguished road
Can you explain what I need to write in the check bounds option is the switch option. Do I need to delete something which is already there.
KaranG is offline   Reply With Quote

Old   July 28, 2017, 08:03
Default
  #8
Senior Member
 
Julio Mendez
Join Date: Apr 2009
Location: Fairburn, GA. USA
Posts: 290
Rep Power: 18
juliom is on a distinguished road
Send a message via Skype™ to juliom
Why don't you try with an easiest problem because I'm seeing you are using MPI. Therefore finding the bug is even more complicated. Compile it using purely fortran and checking bounds as professor Denaro says.
The problem comes because you are reading an address space that does exist, in short, imagine you have an array called u(40,40) and it has 40 elements in each direction. You may be point at an element 41 that are out of bound.
FMDenaro likes this.
juliom is offline   Reply With Quote

Old   July 28, 2017, 17:27
Default
  #9
Senior Member
 
Join Date: Oct 2011
Posts: 239
Rep Power: 16
naffrancois is on a distinguished road
Hello,

The content of "switch" are options given to the compiler and are listed in the following link:

https://gcc.gnu.org/onlinedocs/gcc-4...g-Options.html

It seems then that the compiler used is gcc gfortran, and parallel mpi libraries have been built upon it. You can find on the same webpage useful compiling options for debugging purpose:

https://gcc.gnu.org/onlinedocs/gcc-4...ng-GNU-Fortran.

When debugging a code, as FDenaro and Juliom suggested it is important to check first that arrays are properly allocated and accessed. It is easier to check that first in serial but you have to make sure that you can run this code in serial mode (1 thread). In that case you may replace the variable mpicomp = mpif90 by mpicomp = gfortran

Useful options for the variable "switch": -O0 -fbacktrace -fbounds-check -ffpe-trap=zero,overflow,invalid,underflow. You can read the meaning of these flags on the links above.

An other possible problem may come from insufficient RAM memory. Usually when allocating an array, one should always make a check on memory availability. Then the error may or not appear depending on sufficient resources at runtime. Are you running a case with a lot a degrees of freedom ?

François
juliom and FMDenaro like this.
naffrancois is offline   Reply With Quote

Reply


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault when running dieselFoam or dieselEngineFoam in parallel francesco OpenFOAM Bugs 4 May 2, 2017 21:59
Segmentation fault in SU2 V5.0 ygd SU2 2 March 1, 2017 04:38
Segmentation fault when running in parallel Pj. OpenFOAM Running, Solving & CFD 3 April 8, 2015 08:12
Segmentation Fault w/ compiled OF 2.2.0 - motorBike example sudo OpenFOAM Running, Solving & CFD 3 April 2, 2013 17:27
segmentation fault when installing OF-2.1.1 on a cluster Rebecca513 OpenFOAM Installation 9 July 31, 2012 15:06


All times are GMT -4. The time now is 16:06.