CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Segmentation fault (http://www.cfd-online.com/Forums/openfoam-solving/60668-segmentation-fault.html)

Luiz Eduardo Bittencourt Sampaio (Sampaio) January 6, 2005 21:28

Dear Sirs, After migrating f
 
Dear Sirs,
After migrating from Foam to OpenFoam, a strange thing happened: a new library that used to run nice in old Foam, is presenting a segmentation fault when it is called. Can anyone help me with this?

My library is a v2f model (kev2f.C), under directory $WM_PROJECT_USER_DIR/run/myturbmodels/kev2f/kev2f.C

My Make/files under this directory (.../kev2f) is:
"
kev2f/kev2f.C
kEpsilon/kEpsilon.C

LIB = $(FOAM_USER_LIBBIN)/libmyturbmodels
"

My Make/options in the same directory is:
"
EXE_INC = \
-I$(LIB_SRC)/cfdTools/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/turbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels

LIB_LIBS = \
-lcfdTools \
-lincompressibleTurbulenceModels \
-lincompressibleTransportModels \
-lmeshTools
"

As suggested in User Guide, I copied the foamUser dir to my applications dir ($WM_PROJECT_USER_DIR/applications), and there, in the foamUser/Make, my files and options looks like this:

file:
"
libfoamUser.C
LIB = $(FOAM_LIBBIN)/libfoamUser
"

options:
"
LIB_LIBS = \
-L$(FOAM_USER_LIBBIN) -lmyturbmodels
"

There was no problem in compilation, but I get a segmentation fault when I tried to run.
Can anyone help me?

Regards,
Luiz

Henry Weller (Henry) January 7, 2005 04:36

It's very hard to know what i
 
It's very hard to know what is going wrong from what you have written without having the code to play with. Probably the best thing would be finish it off, pack it up and send it over and I will have a play with it when I get a moment.

Henry

Niklas Nordin (Niklas) January 7, 2005 04:44

Here's what I do when I have
 
Here's what I do when I have this problem. It will probably help u 2.

1. make sure you get a core-dump: i.e. unlimit
2. setenv SIGFPE 1
3. run the case to produce the 'core'-file
4. analyze the core with gdb: gdb whateverFoam core, where 'whateverFoam' is the name of your code
5. in gdb type 'where'

it should tell you which line it crashed, it's also a good idea when you write new code to use the Debug setup, instead of the Opt, since this will give you alot more info.

N

Mattijs Janssens (Mattijs) January 10, 2005 06:02

This is what I usually do whe
 
This is what I usually do when debugging memory faults:

Add in Make/options to the EXE_INC variable

-DFULLDEBUG -g -O0

The FULLDEBUG switch causes all the containers to compile with index checking. (This works only for those files that are being recompiled)

Try to produce a core file, see which routine is the culprit and copy its source file(s) into the local directory and add them to the Make/files list.

Also valgrind can be very useful.

Mattijs


All times are GMT -4. The time now is 15:47.