[petsc-dev] MatDestroySubMatrices_SeqAIJ and reference counting

Hong hzhang at mcs.anl.gov
Fri Jan 12 09:46:11 CST 2018


Stefano:
Sorry, I do not understand your question. Where comes matrix B?
Can you give me an example of this error?
Hong

Hong,
>
> can you explain what’s the rationale behind calling explicitly the Layout
> and header destroy for the submit case in the loop here
> https://bitbucket.org/petsc/petsc/src/ac3af1b492556bac9856a6aee1c739
> 92bd0b1779/src/mat/impls/aij/seq/aij.c?at=master&
> fileviewer=file-view-default#aij.c-2531
>
> A code like this fails since you don’t take into account reference
> counting on the submatrices.
>
> MatCreateSubMatrices(A,….&submats)
> PetscObjectCompose(B,”_XXXX”,submats[0);
> …..
> MatDestroySubMatrices(..,submats);
> MatDestroy(B); //Error, corrupt argument when trying to destroy composed
> objects
>
> Here is a representative valgrind stack trace
>
> ==90133== Invalid read of size 4
> ==90133==    at 0x100368F63: PetscCheckPointer (/Users/szampini/software/
> petsc/src/sys/error/checkptr.c:108)
> ==90133==    by 0x1001ACA9F: PetscObjectDereference
> (/Users/szampini/software/petsc/src/sys/objects/inherit.c:564)
> ==90133==    by 0x10019AC07: PetscObjectListDestroy
> (/Users/szampini/software/petsc/src/sys/objects/olist.c:154)
> ==90133==    by 0x1001A8176: PetscHeaderDestroy_Private
> (/Users/szampini/software/petsc/src/sys/objects/inherit.c:115)
> ==90133==    by 0x100626CAD: MatDestroy (/Users/szampini/software/
> petsc/src/mat/interface/matrix.c:1237)
> ==90133==  Address 0x106c4c320 is 1,632 bytes inside a block of size 4,420
> free'd
> ==90133==    at 0x10014C9F3: free (in /usr/local/Cellar/valgrind/3.
> 13.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
> ==90133==    by 0x100229B7A: PetscFreeAlign (/Users/szampini/software/
> petsc/src/sys/memory/mal.c:88)
> ==90133==    by 0x10022D771: PetscTrFreeDefault (/Users/szampini/software/
> petsc/src/sys/memory/mtr.c:309)
> ==90133==    by 0x100A7034D: MatDestroySubMatrices_SeqAIJ
> (/Users/szampini/software/petsc/src/mat/impls/aij/seq/aij.c:2549)
> ==90133==    by 0x1006260BD: MatDestroySubMatrices
> (/Users/szampini/software/petsc/src/mat/interface/matrix.c:6957)
> ==90133==    by 0x1006D82EC: _DestroyContainer
> ==90133==    by 0x1001AFA31: PetscContainerDestroy
> (/Users/szampini/software/petsc/src/sys/objects/inherit.c:899)
> ==90133==    by 0x1001ACBE5: PetscObjectDereference
> (/Users/szampini/software/petsc/src/sys/objects/inherit.c:566)
> ==90133==    by 0x10019AC07: PetscObjectListDestroy
> (/Users/szampini/software/petsc/src/sys/objects/olist.c:154)
> ==90133==    by 0x1001A8176: PetscHeaderDestroy_Private
> (/Users/szampini/software/petsc/src/sys/objects/inherit.c:115)
> ==90133==    by 0x100626CAD: MatDestroy (/Users/szampini/software/
> petsc/src/mat/interface/matrix.c:1237)
> ==90133==  Block was alloc'd at
> ==90133==    at 0x10014C616: malloc (in /usr/local/Cellar/valgrind/3.
> 13.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
> ==90133==    by 0x1002299AC: PetscMallocAlign (/Users/szampini/software/
> petsc/src/sys/memory/mal.c:48)
> ==90133==    by 0x10022CA73: PetscTrMallocDefault
> (/Users/szampini/software/petsc/src/sys/memory/mtr.c:183)
> ==90133==    by 0x10022B328: PetscMallocA (/Users/szampini/software/
> petsc/src/sys/memory/mal.c:396)
> ==90133==    by 0x100C12E05: MatCreate (/Users/szampini/software/
> petsc/src/mat/utils/gcreate.c:89)
> ==90133==    by 0x100B839F6: MatCreateSubMatrices_MPIAIJ_Local
> (/Users/szampini/software/petsc/src/mat/impls/aij/mpi/mpiov.c:2554)
> ==90133==    by 0x100B7DEE7: MatCreateSubMatrices_MPIAIJ
> (/Users/szampini/software/petsc/src/mat/impls/aij/mpi/mpiov.c:2038)
> ==90133==    by 0x10066703A: MatCreateSubMatrices
> (/Users/szampini/software/petsc/src/mat/interface/matrix.c:6806)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20180112/ceeb38bc/attachment.html>


More information about the petsc-dev mailing list