[petsc-users] Global Vector Generated from Section memory error

Barry Smith bsmith at petsc.dev
Wed Dec 28 14:50:41 CST 2022


  This is a mysterious stack. It is inside memalign() that Valgrind has found the code is accessing memory outside of the block size allocated, but memalign() is presumably the routine that is in the middle of the process of doing the allocation!  This could indicate some (undetected) memory corruption has occurred earlier in the run thus memalign() has corrupted data structures. I presume this is the first warning message?

  You can try running without Valgrind but with the PETSc option -malloc_debug and see if that detects corruption more clearly.

   Barry


> On Dec 28, 2022, at 2:10 PM, Nicholas Arnold-Medabalimi <narnoldm at umich.edu> wrote:
> 
> Hi Petsc Users
> 
> I've been working with vectors generated from a DM and getting some odd memory errors. Using Valgrind, I have been able to trace the issue to DMCreateGlobalVector. I've reduced the code to a relatively simple routine (very similar to example 7) and attached it. I suspect the issue comes down to something improperly set in the section. The code, when integrated, will run correctly 10-30% of the time and otherwise give a memory corruption error.
> 
>  Any insight on the issue or possible error on my part would be appreciated.
> 
> 
> Using Valgrind, I get the following error. 
> 
> ==27064== Invalid write of size 8
> ==27064==    at 0x10C91E: main (section_vector_build.cpp:184)
> ==27064==  Address 0xc4aa248 is 4 bytes after a block of size 3,204 alloc'd
> ==27064==    at 0x483E0F0: memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==27064==    by 0x483E212: posix_memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==27064==    by 0x4C4DAB0: PetscMallocAlign (mal.c:54)
> ==27064==    by 0x4C5262F: PetscTrMallocDefault (mtr.c:186)
> ==27064==    by 0x4C501F7: PetscMallocA (mal.c:420)
> ==27064==    by 0x527E8A9: VecCreate_MPI_Private (pbvec.c:485)
> ==27064==    by 0x527F04F: VecCreate_MPI (pbvec.c:523)
> ==27064==    by 0x53E7097: VecSetType (vecreg.c:89)
> ==27064==    by 0x527FBC8: VecCreate_Standard (pbvec.c:547)
> ==27064==    by 0x53E7097: VecSetType (vecreg.c:89)
> ==27064==    by 0x6CD77C0: DMCreateGlobalVector_Section_Private (dmi.c:58)
> ==27064==    by 0x61D52DB: DMCreateGlobalVector_Plex (plexcreate.c:4130)
> 
> 
> 
> -- 
> Nicholas Arnold-Medabalimi
> 
> Ph.D. Candidate
> Computational Aeroscience Lab
> University of Michigan
> <section_vector_build.cpp>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221228/adaad6c3/attachment.html>


More information about the petsc-users mailing list