[petsc-dev] Fix for long-standing bug in DMMeshRestoreCoordinatesF90 and DMMeshRestoreElementsF90

Blaise Bourdin bourdin at lsu.edu
Wed Jun 8 10:47:50 CDT 2011


Hi,

After poking a bit, I found out the bug causing a segfault in the above-mentioned functions. It seems that gfortran will gladly nullify a bogus pointer, whereas ifort can be a bit pickier, hence the bug coming up only with intel compilers. 
Can you check that the following patch makes sense and if so apply it to petsc-dev?

Thanks,

Blaise

--- a/src/dm/impls/mesh/f90-custom/zmeshf90.c	Tue Jun 07 23:08:25 2011 -0500
+++ b/src/dm/impls/mesh/f90-custom/zmeshf90.c	Wed Jun 08 09:54:14 2011 -0500
@@ -31,7 +31,7 @@ void PETSC_STDCALL dmmeshrestorecoordina
{
  PetscReal *c;
  *__ierr = F90Array2dAccess(ptr,PETSC_REAL,(void**)&c PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
-  *__ierr = F90Array2dDestroy(&ptr,PETSC_REAL PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
+  *__ierr = F90Array2dDestroy(ptr,PETSC_REAL PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
  *__ierr = PetscFree(c);
}
void PETSC_STDCALL dmmeshgetelementsf90_(DM *dm,F90Array2d *ptr,int *__ierr PETSC_F90_2PTR_PROTO(ptrd))
@@ -45,7 +45,7 @@ void PETSC_STDCALL dmmeshrestoreelements
{
  PetscInt   *v;
  *__ierr = F90Array2dAccess(ptr,PETSC_INT,(void**)&v PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
-  *__ierr = F90Array2dDestroy(&ptr,PETSC_INT PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
+  *__ierr = F90Array2dDestroy(ptr,PETSC_INT PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
  *__ierr = PetscFree(v);
}
void PETSC_STDCALL dmmeshgetconef90_(DM *dm,PetscInt *p,F90Array1d *ptr,int *__ierr PETSC_F90_2PTR_PROTO(ptrd))
@@ -56,7 +56,7 @@ void PETSC_STDCALL dmmeshgetconef90_(DM 
}
void PETSC_STDCALL dmmeshrestoreconef90_(DM *dm,F90Array1d *ptr,int *__ierr PETSC_F90_2PTR_PROTO(ptrd))
{
-  *__ierr = F90Array2dDestroy(&ptr,PETSC_INT PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
+  *__ierr = F90Array2dDestroy(ptr,PETSC_INT PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
}

#if 0
@@ -64,7 +64,7 @@ void PETSC_STDCALL dmmeshrestoreclosuref
{
  PetscReal *c;
  *__ierr = F90Array1dAccess(ptr,PETSC_REAL,(void**)&c PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
-  *__ierr = F90Array1dDestroy(&ptr,PETSC_REAL PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
+  *__ierr = F90Array1dDestroy(ptr,PETSC_REAL PETSC_F90_2PTR_PARAM(ptrd));if (*__ierr) return;
  *__ierr = PetscFree(c);
}
#endif
-- 
Department of Mathematics and Center for Computation & Technology
Louisiana State University, Baton Rouge, LA 70803, USA
Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276 http://www.math.lsu.edu/~bourdin










More information about the petsc-dev mailing list