[petsc-users] Segmentation faults: Derived types
Barry Smith
bsmith at mcs.anl.gov
Fri Aug 5 15:54:07 CDT 2016
> 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
More information about the petsc-users
mailing list