|
[Sponsors] |
July 27, 2017, 10:28 |
Segmentation fault
|
#1 |
New Member
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9 |
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. |
|
July 27, 2017, 11:21 |
|
#2 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71 |
Have you compiled it using Fortran compiler and if yes, have you used the check bound options?
|
|
July 28, 2017, 02:38 |
|
#3 |
New Member
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9 |
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 |
|
July 28, 2017, 03:26 |
|
#4 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71 |
I strongly suggest to debug your code without optimizations of any type and supplying the options for the check bounds array.
|
|
July 28, 2017, 04:46 |
|
#5 |
New Member
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9 |
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? |
|
July 28, 2017, 05:02 |
|
#6 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71 |
"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.
|
|
July 28, 2017, 05:15 |
|
#7 |
New Member
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9 |
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.
|
|
July 28, 2017, 08:03 |
|
#8 |
Senior Member
|
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. |
|
July 28, 2017, 17:27 |
|
#9 |
Senior Member
Join Date: Oct 2011
Posts: 239
Rep Power: 16 |
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 |
|
|
|
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 |