[petsc-users] Double free in KSPDestroy
Florian Lindner
mailinglists at xgm.de
Mon Jul 13 10:56:52 CDT 2015
Hello,
our petsc application suffers from a memory error (double free or corruption).
Situation is a like that:
A KSP is private member of a C++ class. In its constructor I call KSPCreate. Inbetween it may haben that I call KSPREset. In the class' destructor I call KSPDestroy. That's where the memory error appears:
gdb backtrace:
#4 0x00007ffff490b8db in _int_free () from /usr/lib/libc.so.6
#5 0x00007ffff6188c9c in PetscFreeAlign (ptr=0xfcd990, line=258, func=0x7ffff753c4c8 <__func__.20304> "KSPReset_GMRES", file=0x7ffff753b8b0 "/home/florian/software/petsc/src/ksp/ksp/impls/gmres/gmres.c")
at /home/florian/software/petsc/src/sys/memory/mal.c:72
#6 0x00007ffff6ff6cdc in KSPReset_GMRES (ksp=0xf48470) at /home/florian/software/petsc/src/ksp/ksp/impls/gmres/gmres.c:258
#7 0x00007ffff70ad804 in KSPReset (ksp=0xf48470) at /home/florian/software/petsc/src/ksp/ksp/interface/itfunc.c:885
#8 0x00007ffff70ae2e8 in KSPDestroy (ksp=0xeb89d8) at /home/florian/software/petsc/src/ksp/ksp/interface/itfunc.c:933
#9 0x0000000000599b24 in precice::mapping::PetRadialBasisFctMapping<precice::mapping::Gaussian>::~PetRadialBasisFctMapping (this=0xeb8960) at src/mapping/PetRadialBasisFctMapping.hpp:148
#10 0x0000000000599bc9 in precice::mapping::PetRadialBasisFctMapping<precice::mapping::Gaussian>::~PetRadialBasisFctMapping (this=0xeb8960) at src/mapping/PetRadialBasisFctMapping.hpp:146
Complete backtrace at http://pastebin.com/ASjibeNF
Could it be a problem it objects set by KSPSetOperators are destroyed afterwards? I don't think so, since KSPReset is called before.
I've wrapped a class (just a bunch of helper function, no encapsulating wrapper) round Mat and Vec objects. Nothing fancy, the ctor calls MatCreate, the dtor MatDestroy, you can have a look at https://github.com/precice/precice/blob/develop/src/mapping/petnum.cpp / .hpp.
These objects are also members of the same class like KSP, so their dtor is called after KSPDestroy.
What could cause the memory corruption here?
Thanks a lot,
Florian
More information about the petsc-users
mailing list