Author Topic: Feap 8.3 with gcc-5, gfortran-5  (Read 5699 times)

dkienle

  • New Member
  • *
  • Posts: 2
Feap 8.3 with gcc-5, gfortran-5
« on: March 06, 2019, 06:10:07 AM »
Dear FEAP Team & Users,

I have Problems in compiling Feap 8.3 with gcc-5, gfortran-5 on Ubuntu 18.04.

It compiles but I get an error when I run it (while initialization):
Memory allocation error
 CALLOC() returns NULL pointer
Note: The following floating-point exceptions are signalling: IEEE_DIVIDE_BY_ZERO

I checked the line of code where this message comes from: cmem.c:214. At that line "calloc" is called and returns somehow a NULL pointer. Calling "calloc" in a separate program with the same arguments works fine

GDB gives me following:
Backtrace for this error:
#0  0x7fb489641ea7 in ? ? ?
#1  0x7fb4896410dd in ? ? ?
#2  0x7fb488cbdf1f in ? ? ?
#3  0x7fb488d30143 in  ? ? ?
#4  0x7fb488cda431 in ? ? ?
#5  0x7fb488ce3f25 in ? ? ?
#6  0x564e68392862 in ? ? ?
#7  0x564e68392c0b in ? ? ?
#8  0x564e68541367 in setmem_
   at ../unix/setmem.f:83
#9  0x564e683d43e8 in usetmem_
   at ../program/usetmem.f:55
#10  0x564e6839414d in ualloc_
   at ../user/ualloc.f:58
#11  0x564e6818af5f in palloc_
   at ../program/palloc.f:630
#12  0x564e6818f40a in pnewprob_
   at ../program/pnewprob.f:507
#13  0x564e68124b99 in pcontr_
   at ../program/pcontr.f:894
#14  0x564e68107c28 in feap
   at ../main/feap83.f:215
#15  0x564e68107c61 in main
   at ../main/feap83.f:221
rlwrap: warning: feap crashed, killed by SIGSEGV (core dumped).

However compiling it with  gcc-4.8, gfortran-4.8 or icc-17,ifort-17 works fine. The executable works also fine.

Actually i want to use gfortran-7.3 but for this version and also for gfortran-6 I get the same behavior.

Is such a problem known or are there any solutions?

Kind regards
dkienle

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Feap 8.3 with gcc-5, gfortran-5
« Reply #1 on: March 06, 2019, 08:06:21 AM »
These compiler/os combinations should work just fine.  It is hard to say what is occurring.

The only thing I can really suggest is to make sure that you have a completely clean build
tree and then build from scratch to make sure there are no *.o files from other builds laying around.

The other thing to watch out for is that v8.3 will start to get difficult to compile with newer
compilers, since they tend to be more picky with Fortran rule checking.

dkienle

  • New Member
  • *
  • Posts: 2
Re: Feap 8.3 with gcc-5, gfortran-5
« Reply #2 on: March 25, 2019, 05:09:39 AM »
So I found a fix/workaround for my issue.

in unix/cmem.c:214: calloc is called, somehow the sum inside the argument of calloc is not evaluated correctly. I changed this line:
Code: [Select]
p       = (byte*) calloc(len + 1 + cmem_chunks, 8);to that:
Code: [Select]
int a = len + 1 + cmem_chunks;
p       = (byte*) calloc(a, 8);

I did the same for realloc  (unix/cmem.c:277):
Code: [Select]
q        = (byte*) realloc(p, (len + 1 + cmem_chunks)*8);to:
Code: [Select]
int a = (len + 1 + cmem_chunks)*8;
q        = (byte*) realloc(p, a);

Then I ran in to the next problem with naninfck.f but this was resolved by:
http://feap.berkeley.edu/forum/index.php?topic=1310.0


Theses changes in unix/cmem.c and program/naninfck.f fixed my problems.
(OS: Linux Mint 19, Kernel: 4.15.0-20-generic, compiler: gcc/gfortran 7.3.0)

Kind regards
dkienle

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Feap 8.3 with gcc-5, gfortran-5
« Reply #3 on: March 25, 2019, 02:53:09 PM »
Interesting. Can you tell me what you are now getting in 'a'?  And what the code thought was there before?

[I would also be curious what happens if you were to use -O0 (so no optimization) when compiling cmem.c]