[petsc-dev] XXXRegisterDestroy() are not called

Barry Smith bsmith at mcs.anl.gov
Fri Apr 5 20:01:45 CDT 2013


   Folks,

    Currently we have all these XXXRegisterDestroy() routines that are not called

petscao.h:PETSC_EXTERN PetscErrorCode AORegisterDestroy(void);
petsccharacteristic.h:PETSC_EXTERN PetscErrorCode CharacteristicRegisterDestroy(void);
petscdm.h:PETSC_EXTERN PetscErrorCode DMRegisterDestroy(void);
petscdraw.h:PETSC_EXTERN PetscErrorCode PetscDrawRegisterDestroy(void);
petscis.h:PETSC_EXTERN PetscErrorCode ISRegisterDestroy(void);
petscksp.h:PETSC_EXTERN PetscErrorCode KSPRegisterDestroy(void);
petscmat.h:PETSC_EXTERN PetscErrorCode MatOrderingRegisterDestroy(void);
petscmat.h:PETSC_EXTERN PetscErrorCode MatColoringRegisterDestroy(void);
petscmat.h:PETSC_EXTERN PetscErrorCode MatPartitioningRegisterDestroy(void);
petscmat.h:PETSC_EXTERN PetscErrorCode MatCoarsenRegisterDestroy(void);
petscmat.h:PETSC_EXTERN PetscErrorCode MatMFFDRegisterDestroy(void);
petscpc.h:PETSC_EXTERN PetscErrorCode PCRegisterDestroy(void);
petscpf.h:PETSC_EXTERN PetscErrorCode PFRegisterDestroy(void);
petscsf.h:PETSC_EXTERN PetscErrorCode PetscSFRegisterDestroy(void);
petscsnes.h:PETSC_EXTERN PetscErrorCode SNESRegisterDestroy(void);
petscsnes.h:PETSC_EXTERN PetscErrorCode SNESLineSearchRegisterDestroy(void);
petscsnes.h:PETSC_EXTERN PetscErrorCode SNESMSRegisterDestroy(void);
petscsys.h:PETSC_EXTERN PetscErrorCode PetscObjectRegisterDestroy(PetscObject);
petscsys.h:PETSC_EXTERN PetscErrorCode PetscObjectRegisterDestroyAll(void);
petscsys.h:PETSC_EXTERN PetscErrorCode PetscRandomRegisterDestroy(void);
petscthreadcomm.h:PETSC_EXTERN PetscErrorCode PetscThreadCommRegisterDestroy(void);
petscts.h:PETSC_EXTERN PetscErrorCode TSRegisterDestroy(void);
petscts.h:PETSC_EXTERN PetscErrorCode TSAdaptRegisterDestroy(void);
petscts.h:PETSC_EXTERN PetscErrorCode TSGLAdaptRegisterDestroy(void);
petscts.h:PETSC_EXTERN PetscErrorCode TSGLRegisterDestroy(void);
petscts.h:PETSC_EXTERN PetscErrorCode TSARKIMEXRegisterDestroy(void);
petscts.h:PETSC_EXTERN PetscErrorCode TSRosWRegisterDestroy(void);
petscvec.h:PETSC_EXTERN PetscErrorCode VecRegisterDestroy(void);
petscviewer.h:PETSC_EXTERN PetscErrorCode PetscViewerRegisterDestroy(void);

The only one that is called is PetscThreadCommRegisterDestroy() and that is actually a (harmless) bug.

Currently PetscFunctionListAdd() maintains a list of all function lists in existence and in PetscFinalize() PetscFunctionListDestroyAll() loops over all the list of lists destroying each list. Thus all of these lists are destroyed without the XXXRegisterDestroy() needing to be called. A drawback is that PetscFunctionListDestroyAll() is called before some of the XXXFinalizePackage() are called thus leaving XXXList global variables pointing to freed memory (this is why for example VecFinalizePackage() has   VecList               = NULL; in it.) 

  I propose the following change; each appropriate XXXFinalizePackage() call the appropriate XXXRegisterDestroy() (this would replace the VecList               = NULL; lines) and PetscFunctionListDestroyAll() be renamed to just generate a dump of any lists that don't get properly freed. 

   Comments? I'd like to do it soon so it gets tested before the release but it is pretty straightforward,

  Barry










More information about the petsc-dev mailing list