[petsc-users] Segmentation faults: Derived types

Santiago Ospina De Los Rios sospinar at unal.edu.co
Fri Aug 5 23:34:49 CDT 2016


Dear Barry,

I tried to build a simple code with the same things I mentioned to you on
last e-mail but it worked, which is more strange to me. So I built two
branches on my git code to show you the problem:

git code: https://github.com/SoilRos/ANISOFLOWPACK

Branch:  PETSc_debug_boolean_0
The first one is a simple code which is working for what was designed.
Forget sample problems, just compile and run the ANISOFLOW executable on
src folder, if there are some verbose messages then the program is working.

Branch:  PETSc_debug_boolean_1
The second one is just a modification of the first one adding the two
booleans mentioned above in 01_Types.F90 file. I tried it in mac El Capitan
and Ubuntu (with Valgrind) and PETSc 3.7.3 and 3.7.2 respectively, both
with the same segmentation fault.

PD: Although I already fixed it compressing the three booleans into one
integer, I think is better if we try to figure out why there is a
segmentation fault because I had similar problems before.
PD2: Please obviate the variable description because are pretty out of
date. I'm trying to change it, so it can be confusing.

Best wishes,
Santiago Ospina

2016-08-05 15:54 GMT-05:00 Barry Smith <bsmith at mcs.anl.gov>:

>
> > On Aug 1, 2016, at 4:41 PM, Santiago Ospina De Los Rios <
> sospinar at unal.edu.co> wrote:
> >
> > Hello there,
> >
> > I'm having problems defining some variables into derived types in
> Fortran. Before, I had a similar problems with an allocatable array
> "PetsInt" but I solved it just doing a non-collective Petsc Vec. Today I'm
> having troubles with "PetscBool" or "Logical":
> >
> > In a module which define the variables, I have the following:
> >
> > MODULE ANISOFLOW_Types
> >
> >     IMPLICIT NONE
> >
> > #include <petsc/finclude/petscsys.h>
> > #include <petsc/finclude/petscvec.h>
> >
> > ...
> >
> >      TYPE ConductivityField
> >          PetscBool                               ::
> DefinedByCvtZones=.FALSE.    ! It produces the segmentation fault.
> >          PetscBool                               ::
> DefinedByPptZones=.FALSE.    ! It produces the segmentation fault.
> >          PetscBool                               :: DefinedByCell=.FALSE.
> >          ! Conductivity defined by zones (Local):
> >          Vec                                     :: ZoneID
> >          TYPE(Tensor),ALLOCATABLE                :: Zone(:)
> >          ! Conductivity defined on every cell (Local):
> >          Vec                                     :: Cell
> >      END TYPE ConductivityField
> >
> >
> >     TYPE SpecificStorageField
> >         PetscBool                               ::
> DefinedByStoZones=.FALSE.    ! It produces the segmentation fault.
> >         PetscBool                               ::
> DefinedByPptZones=.FALSE.    ! It produces the segmentation fault.
> >         PetscBool                               :: DefinedByCell=.FALSE.
> >         ! Specific Storage defined by zones (Local):
> >         Vec                                     :: ZoneID
> >         Vec                                     :: Zone
> >         ! Specific Storage defined on every cell (Global).:
> >         Vec                                     :: Cell
> >     END TYPE SpecificStorageField
> >
> >     TYPE PropertiesField
> >         TYPE(ConductivityField)         :: Cvt
> >         TYPE(SpecificStorageField)      :: Sto
> >         ! Property defined by zones (Local):
> >         PetscBool                       :: DefinedByPptZones=.FALSE.
> >         Vec                             :: ZoneID
> >     END TYPE PropertiesField
> >
> > ...
> >
> > CONTAINS
> >
> > ...
> >
> > END MODULE ANISOFLOW_Types
> >
> >
> > Later I use it in the main program, with something like this
> >
> > PROGRAM ANISOFLOW
> >
> >     USE ANISOFLOW_Types,                ONLY : ... ,PropertiesField, ...
> >     ...
> >
> >     IMPLICIT NONE
> >
> > #include <petsc/finclude/petscsys.h>
> >
> >     ...
> >     TYPE(PropertiesField)       :: PptFld
> >     ...
> >
> >     CALL PetscInitialize(PETSC_COMM_WORLD,ierr)
> >     ...
> >     CALL PetscFinalize(ierr)
> >
> > END PROGRAM
> >
> >
> > When I run the program appears a Segmentation Fault, which disappears
> when I comment the booleans marked in the code. Because I need them, I used
> Valgrind to figure out what is happening but it is yet a mistery to me.
> >
> > Valgrind message:
> > ==5160==
> > ==5160== Invalid read of size 1
>
>    It is curious that it says "of size 1" when we declare PetscBool to be
> a logical*4 I don't see anything obviously wrong.
>
>    Please send a simple code we can compile and run that reproduces the
> problem.
>
>    Barry
> > ==5160==    at 0x4FB2156: petscinitialize_ (zstart.c:433)
> > ==5160==    by 0x4030EA: MAIN__ (ANISOFLOW.F90:29) # line of petsc
> inizalitation
> > ==5160==    by 0x404380: main (ANISOFLOW.F90:3) # line of "USE
> ANISOFLOW_Types,                ONLY : ... ,PropertiesField, ..."
> > ==5160==  Address 0xc54fff is not stack'd, malloc'd or (recently) free'd
> > ==5160==
> >
> > Program received signal SIGSEGV: Segmentation fault - invalid memory
> reference.
> >
> > Backtrace for this error:
> > #0  0x699E777
> > #1  0x699ED7E
> > #2  0x6F0BCAF
> > #3  0x4FB2156
> > #4  0x4030EA in anisoflow at ANISOFLOW.F90:29
> >
> > I think it is maybe related with petsc because the error popped out just
> in its initialization, so if you know what's going on, I would appreciate
> to tell me.
> >
> > Santiago Ospina
> > --
> >
> > --
> > Att:
> >
> > Santiago Ospina De Los Ríos
> > National University of Colombia
>
>


-- 

-- 
Att:

Santiago Ospina De Los Ríos
National University of Colombia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160805/08541262/attachment.html>


More information about the petsc-users mailing list