<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">Hi PETSc-developers, </p>
<p style="margin:0px 0px 1.2em!important">While trying to use <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">MatGetRowMax</code>, I’m getting the following error : </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind">https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind</a>
[0]PETSC ERROR: or try <a href="http://valgrind.org">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: likely location of problem given in stack below
[0]PETSC ERROR: --------------------- Stack Frames ------------------------------------
[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,
[0]PETSC ERROR: INSTEAD the line number of the start of the function
[0]PETSC ERROR: is given.
[0]PETSC ERROR: [0] MatGetRowMax_SeqAIJ line 3182 /home/sajid/packages/petsc/src/mat/impls/aij/seq/aij.c
[0]PETSC ERROR: [0] MatGetRowMax line 4798 /home/sajid/packages/petsc/src/mat/interface/matrix.c
[0]PETSC ERROR: [0] MatGetRowMax_MPIAIJ line 2432 /home/sajid/packages/petsc/src/mat/impls/aij/mpi/mpiaij.c
[0]PETSC ERROR: [0] MatGetRowMax line 4798 /home/sajid/packages/petsc/src/mat/interface/matrix.c
[0]PETSC ERROR: [0] construct_matrix line 25 /home/sajid/Documents/intern/pirt/src/matrix.cxx
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Signal received
[0]PETSC ERROR: See <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html">https://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.13.5-2756-g0264f47704 GIT Date: 2020-09-06 15:08:48 -0500
[0]PETSC ERROR: /home/sajid/Documents/intern/pirt/src/pirt on a arch-linux-c-debug named xrm-backup by sajid Tue Sep 8 13:56:53 2020
[0]PETSC ERROR: Configure options --with-hdf5=1 --with-debugging=yes
[0]PETSC ERROR: #1 User provided function() line 0 in unknown file
application called MPI_Abort(MPI_COMM_WORLD, 50161059) - process 0
</code></pre><p style="margin:0px 0px 1.2em!important">Could someone point out what could cause such a segfault ? </p>
<p style="margin:0px 0px 1.2em!important">PS : Should it be useful, the error occurs in the (nested) call to <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">MatGetRowMax</code> for the off-diagonal SeqAIJ matrix and the segmentation violation occurs for the first row of a matrix whose ncols=0 (for the off diagonal part).</p>
<p style="margin:0px 0px 1.2em!important"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">MatGetOwnershipRangeColumn</code> was used to set the diagonal and off-diagonal preallocation and all the columns were set to be in the diagonal SeqAIJ matrix as shown below : </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">(gdb) frame
#0 MatGetRowMax (mat=0x7ed340, v=0x982470, idx=0x0) at /home/sajid/packages/petsc/src/mat/interface/matrix.c:4803
4803 if (!mat->ops->getrowmax) SETERRQ1(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"Mat type %s",((PetscObject)mat)->type_name);
(gdb) print mat->cmap->rstart
$12 = 0
(gdb) print mat->cmap->rend
$13 = 65536
(gdb) step
4804 MatCheckPreallocated(mat,1);
(gdb) next
4806 ierr = (*mat->ops->getrowmax)(mat,v,idx);CHKERRQ(ierr);
(gdb) next
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff60ca248 in MatGetRowMax_SeqAIJ (A=0x8d1450, v=0x9b1220, idx=0x99a620) at /home/sajid/packages/petsc/src/mat/impls/aij/seq/aij.c:3195
3195 x[i] = *aa; if (idx) idx[i] = 0;
(gdb)
</code></pre><p style="margin:0px 0px 1.2em!important">Thank You,<br>Sajid Ali | PhD Candidate<br>Applied Physics<br>Northwestern University<br><a href="http://s-sajid-ali.github.io">s-sajid-ali.github.io</a></p>
<div title="MDH:PGRpdj48ZGl2PjxkaXY+SGkgUEVUU2MtZGV2ZWxvcGVycywgPGJyPjxicj48L2Rpdj5XaGlsZSB0
cnlpbmcgdG8gdXNlIGBNYXRHZXRSb3dNYXhgLCBJJ20gZ2V0dGluZyB0aGUgZm9sbG93aW5nIGVy
cm9yIDogPGJyPmBgYDxicj5bMF1QRVRTQyBFUlJPUjogLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t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