<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> 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?<div><br></div><div> You can try running without Valgrind but with the PETSc option -malloc_debug and see if that detects corruption more clearly.</div><div><br></div><div> Barry</div><div><br><div><br><blockquote type="cite"><div>On Dec 28, 2022, at 2:10 PM, Nicholas Arnold-Medabalimi <narnoldm@umich.edu> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr">Hi Petsc Users<br><br>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.<br><br> Any insight on the issue or possible error on my part would be appreciated.<br><br><br>Using Valgrind, I get the following error. <br><br>==27064== Invalid write of size 8<br>==27064== at 0x10C91E: main (section_vector_build.cpp:184)<br>==27064== Address 0xc4aa248 is 4 bytes after a block of size 3,204 alloc'd<br>==27064== at 0x483E0F0: memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)<br>==27064== by 0x483E212: posix_memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)<br>==27064== by 0x4C4DAB0: PetscMallocAlign (mal.c:54)<br>==27064== by 0x4C5262F: PetscTrMallocDefault (mtr.c:186)<br>==27064== by 0x4C501F7: PetscMallocA (mal.c:420)<br>==27064== by 0x527E8A9: VecCreate_MPI_Private (pbvec.c:485)<br>==27064== by 0x527F04F: VecCreate_MPI (pbvec.c:523)<br>==27064== by 0x53E7097: VecSetType (vecreg.c:89)<br>==27064== by 0x527FBC8: VecCreate_Standard (pbvec.c:547)<br>==27064== by 0x53E7097: VecSetType (vecreg.c:89)<br>==27064== by 0x6CD77C0: DMCreateGlobalVector_Section_Private (dmi.c:58)<br>==27064== by 0x61D52DB: DMCreateGlobalVector_Plex (plexcreate.c:4130)<br><br><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font>Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font><br>Computational Aeroscience Lab<br>University of Michigan</font></div></div></div></div></div></div>
<span id="cid:f_lc817rnn0"><section_vector_build.cpp></span></div></blockquote></div><br></div></body></html>