Segmentation fault with ccx_2.17


I have built ccx v2.17 but I am getting a segfault when I run the sample ‘couette5fem’ in the test subdirectory. I reran the same sample with ‘valgrind’ and it seems the error happens in the printoutint() subroutine.
Following is an excerpt from the valgrind log:

==6128== Use of uninitialised value of size 8
==6128==    at 0x7E9E63: printoutint_ (printoutint.f:52)
==6128==    by 0x7E9881: printoutfluidfem_ (printoutfluidfem.f:178)
==6128==    by 0x6DA437: compfluidfem (compfluidfem.c:1277)
==6128==    by 0x561250: nonlingeo (nonlingeo.c:1528)
==6128==    by 0x406423: main (ccx_2.17.c:1208)
==6128==  Uninitialised value was created by a stack allocation
==6128==    at 0x7E87AA: printoutfluidfem_ (printoutfluidfem.f:19)

Here is what the routine looks like in file printoutint.f:

  subroutine printoutint(prlab,ipkon,lakon,stx,eei,xstate,ener,
 &  mi,nstate_,ii,nelem,qfx,orab,ielorien,norien,co,konf,
 &  ielmat,thicke,eme,ielprop,prop,nelel,ithermal,orname)

The subroutine takes 25 parameters, and is called from 3 different files (several times from each file).

File printout.f:

                 call printoutint(prlab,ipkon,lakon,stx,eei,xstate,
 &                    ener,mi(1),nstate_,ii,nelem,qfx,
 &                    orab,ielorien,norien,co,kon,ielmat,thicke,eme,
 &                    ielprop,prop,nelem,ithermal,orname)

File printoutfluid.f:

                 call printoutint(prlab,ipkonf,lakonf,sti,eei,
 &                    xstate,ener,mi(1),nstate_,ii,nelem,qfx,
 &                    orab,ielorienf,norien,co,konf,ielmatf,thicke,
 &                    eme,ielpropf,prop,nelel,ithermal,
 &                    orname)

Fiel printoutfluidfem.f:

                 call printoutint(prlab,ipkon,lakon,sti,eei,xstate,
 &                    ener,mi(1),nstate_,ii,nelem,qfx,
 &                    orab,ielorien,norien,co,kon,ielmat,thicke,eme)

As you can see, in printout.f and printoutfluid.f the subroutine printoutint() is called with all of its 25 parameters. In printoutfluidfem.f, however, every call to printoutint() only passes 20 parameters.

Unfortunately, I am not familiar with fortran and do therefore not know if the calls in printoutfluidfem.f are correctly implemented. Please take a look at it.

Additional information:

I am linking the output of valgrind and the Makefile

Compiler version:
gfortran, version 5.5.0
gcc, version 5.5.0

Slackware64 14.2, (the error also happens on 32-bit architecture)


I am limited to 2 links per post, so here is the output of ccx in a separate post.

For the sake of completeness, you could try to compile with gcc/gfortran 10. gfortran became stricter and the warnings may help you to find the root cause of the issue. Maybe you even try to compile it with a sanitizer.

For more info regarding gcc 10 see Build failures with GCC 10