[petsc-dev] Strange array indexing in MatDestroySubMatrices
Hong
hzhang at mcs.anl.gov
Thu Jul 13 14:55:57 CDT 2017
Stefano:
> I'm not able to reproduce it with the BDDC example ex59.c in KSP tutorials.
> The error comes from the PetscMalloc1 call at
> src/mat/impls/aij/mpi/mpiov.c:1082, which allocates with Malloc and not
> with Calloc.
>
This is a bug. The change
- ierr = PetscMalloc1(1,Bin);CHKERRQ(ierr);
+ ierr = PetscCalloc1(2,Bin);CHKERRQ(ierr);
fix the bug.
https://bitbucket.org/petsc/petsc/commits/a27f7bbfc0dabeb54077f66748454576b9565427
>>> I think what you wrote is conceptually wrong, being in the interface
>>> part of the library.
>>> The extra allocation is not done consistently throughout all the
>>> specific implementations that MatCreateSubMatrices can use.
>>>
>>
How about adding 'destroysubmatrices' into _MatOps table, then move the
extra stuff into MatDestroySubmatrices_xxx()?
Hong
> Here is an excerpt of a valgrind error I'm getting
>>>
>>> ==37303== Conditional jump or move depends on uninitialised value(s)
>>> ==37303== at 0xA94B0D7: MatDestroySubMatrices
>>> (/home/szampini/src/petsc/src/mat/interface/matrix.c:6890)
>>> ==37303== by 0xAFA0400: PCBDDCSubSchursSetUp
>>> (/home/szampini/src/petsc/src/ksp/pc/impls/bddc/bddcschurs.c:1545)
>>> .....
>>> ==37303== Uninitialised value was created by a heap allocation
>>> ==37303== at 0x4C2FF83: memalign (/builddir/build/BUILD/valgrin
>>> d-3.12.0/coregrind/m_replacemalloc/vg_replace_malloc.c:858)
>>> ==37303== by 0x9FA172C: PetscMallocAlign
>>> (/home/szampini/src/petsc/src/sys/memory/mal.c:39)
>>> ==37303== by 0x9FA4044: PetscTrMallocDefault
>>> (/home/szampini/src/petsc/src/sys/memory/mtr.c:183)
>>> ==37303== by 0xA87BE20: MatCreateSubMatrix_MPIAIJ_All
>>> (/home/szampini/src/petsc/src/mat/impls/aij/mpi/mpiov.c:1082)
>>> ==37303== by 0xA8852F1: MatCreateSubMatrices_MPIAIJ
>>> (/home/szampini/src/petsc/src/mat/impls/aij/mpi/mpiov.c:2024)
>>> ==37303== by 0xA9490C3: MatCreateSubMatrices
>>> (/home/szampini/src/petsc/src/mat/interface/matrix.c:6742)
>>> ==37303== by 0xAF9F401: PCBDDCSubSchursSetUp
>>> (/home/szampini/src/petsc/src/ksp/pc/impls/bddc/bddcschurs.c:1506)
>>>
>>> You can see the calling sequence, so that maybe I'm doing something
>>> wrong in bddcschurs.c.
>>>
>>> Thanks,
>>> Stefano
>>>
>>>
>>> 2017-07-12 22:20 GMT+03:00 Hong <hzhang at mcs.anl.gov>:
>>>
>>>> MatCreateSubMatrices_xxx() calloc an array of size n+1, n=ismax and
>>>> submat[n]=null as default.
>>>>
>>>> For MatCreateSubMatrices_MPIAIJ(), I calloc ismax+nstages and use
>>>> submat[n] ... to store some datastructures for reuse.
>>>>
>>>> When submat[n] != null, these data structures are destroyed.
>>>>
>>>> Hong
>>>>
>>>>
>>>> On Wed, Jul 12, 2017 at 11:29 AM, Stefano Zampini <
>>>> stefano.zampini at gmail.com> wrote:
>>>>
>>>>> Is line number 6890 of matrix.c correct???
>>>>>
>>>>> https://bitbucket.org/petsc/petsc/src/b02a13eda23b9fabea7dbf
>>>>> cadcfb98e3258ee49d/src/mat/interface/matrix.c?at=master&file
>>>>> viewer=file-view-default#matrix.c-6890
>>>>>
>>>>> --
>>>>> Stefano
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Stefano
>>>
>>
>>
>
>
> --
> Stefano
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20170713/03c1d661/attachment.html>
More information about the petsc-dev
mailing list