<div dir="ltr">Hi<br><br>Thanks for the help. This was quite confusing, and there is quite an exciting matrix of test results, but I think this is resolved. <br><br>Basically, I was playing fast and loose with using a local section to get offsets for a global vector. When I instead used a global section and subtracted the ownership range from the offset, everything seemed to be working okay. <br><br>What remains a mystery is why was the stack trace pointing to the GlobalVectorCreate instead of the assignment statement to the Scalar array grabbed using VecGetArray? <br><br><br>Thanks <br>Nicholas<br><br><br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 28, 2022 at 3:51 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><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 <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</a>> wrote:</div><br><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"><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="m_6461954674675174690cid:f_lc817rnn0"><section_vector_build.cpp></span></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></div></div></div></div></div>