<div dir="ltr">Maybe there is a bug in the Register() code.<div><br></div><div>   Matt</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 2, 2021 at 4:43 PM Mark Adams <<a href="mailto:mfadams@lbl.gov">mfadams@lbl.gov</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 dir="ltr">I see the problem, but not the solution. I put a print statement in MatSolverTypeDestroy and see:<div><br></div><div>MatSolverTypeDestroy seqaij inext->next=0x7fb4a9114c70 inext=0x7fb4a9113c70<br></div><div><br></div><div>before it fails. This seqaij node seems to be pointing to itself. If I remove my registration call and it works and I see this from my print statement:</div><div><br></div><div>MatSolverTypeDestroy seqaij inext->next=0x7fe811827270 inext=0x7fe811826270<br>MatSolverTypeDestroy seqaijperm inext->next=0x7fe811909c70 inext=0x7fe811827270<br>MatSolverTypeDestroy constantdiagonal inext->next=0x7fe81190ac70 inext=0x7fe811909c70<br></div><div> ....</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 2, 2021 at 3:42 PM Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</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 dir="ltr">I am trying to add a band solver to PETSc (later to be moved to Cuda and Kokkos) and I have started by adding some types and a copy of the current LU as placeholders. I register with:<div><br></div><div> ierr = MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ,        MAT_FACTOR_LUBAND,MatGetFactor_seqaij_petsc);CHKERRQ(ierr);<br></div><div><br></div><div>And that is about all that I do that can have any effect at this point. I add a switch in  MatGetFactor_seqaij_petsc on (ftype == MAT_FACTOR_LUBAND) to set the symbolic factorization method (*B)->ops->lufactorsymbolic  = MatLUBandFactorSymbolic_SeqAIJ; But this is not called (I verified this) because I don't know how to get MatGetFactor_seqaij_petsc to receive ftype == MAT_FACTOR_LUBAND. (I need help on this to)</div><div><br></div><div>Anyway, I would hope that these changes would not do anything but I get an error (appended).</div><div><br></div><div>It is failing in MatSolverTypeDestroy on this second PetscFree:</div><div><br></div><div>    while (inext) {<br>      ierr = PetscFree(inext->mtype);CHKERRQ(ierr);<br>      iprev = inext;<br>      inext = inext->next;<br>      ierr = PetscFree(iprev);CHKERRQ(ierr);<br>    }<br></div><div><br></div><div>I tried to clone LU here, but I clearly missed something.</div><div><br></div><div>Any ideas?</div><div><br></div><div>And I just made  an MR for this if you want to look at the code.</div><div><br></div><div>Thanks,</div><div>Mark</div><div>...</div><div>Number of SNES iterations = 2<br>[0]PETSC ERROR: PetscTrFreeDefault() called from MatSolverTypeDestroy() line 4513 in /Users/markadams/Codes/petsc/src/mat/interface/matrix.c<br>[0]PETSC ERROR: Block [id=0(48)] at address 0x7fb7fb8f7620 is corrupted (probably write past end of array)<br>[0]PETSC ERROR: Block allocated in MatSolverTypeRegister() line 4382 in /Users/markadams/Codes/petsc/src/mat/interface/matrix.c<br>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>[0]PETSC ERROR: Memory corruption: <a href="https://www.mcs.anl.gov/petsc/documentation/installation.html#valgrind" target="_blank">https://www.mcs.anl.gov/petsc/documentation/installation.html#valgrind</a><br>[0]PETSC ERROR: Corrupted memory<br>[0]PETSC ERROR: See <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">https://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>[0]PETSC ERROR: Petsc Development GIT revision: v3.14.4-739-g575f931ef8  GIT Date: 2021-03-02 13:38:55 -0500<br>[0]PETSC ERROR: ./ex19 on a arch-macosx-gnu-g named MarksMac-302.local by markadams Tue Mar  2 15:28:41 2021<br>[0]PETSC ERROR: Configure options --with-mpi-dir=/usr/local/Cellar/mpich/3.3.2_1 COPTFLAGS="-g -O0" CXXOPTFLAGS="-g -O0" --download-metis=1 --download-parmetis=1 --download-kokkos=1 --download-kokkos-kernels=1 --download-p4est=1 --with-zlib=1 --download-superlu_dist --download-superlu --with-make-np=4 --download-hdf5=1 -with-cuda=0 --with-x=0 --with-debugging=1 PETSC_ARCH=arch-macosx-gnu-g --with-64-bit-indices=0 --with-openmp=0 --with-ctable=0<br>[0]PETSC ERROR: #1 PetscTrFreeDefault() line 310 in /Users/markadams/Codes/petsc/src/sys/memory/mtr.c<br>[0]PETSC ERROR: #2 MatSolverTypeDestroy() line 4513 in /Users/markadams/Codes/petsc/src/mat/interface/matrix.c<br>[0]PETSC ERROR: #3 MatFinalizePackage() line 57 in /Users/markadams/Codes/petsc/src/mat/interface/dlregismat.c<br>[0]PETSC ERROR: #4 PetscRegisterFinalizeAll() line 389 in /Users/markadams/Codes/petsc/src/sys/objects/destroy.c<br>[0]PETSC ERROR: #5 PetscFinalize() line 1474 in /Users/markadams/Codes/petsc/src/sys/objects/pinit.c<br></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div>