<div dir="ltr">Hi Jason,<div><br></div><div>Thank you for your help. I corrected ,recompiled the code and the error has gone.</div><div><br></div><div>Khai</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Mon, Aug 11, 2014 at 10:17 AM, Jason Sarich <span dir="ltr"><<a href="mailto:jason.sarich@gmail.com" target="_blank">jason.sarich@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Khai<br>
<br>
The likely culprit is in petsc/src/vec/vec/utils/projection.c, at the<br>
end of the VecMedian() there are three calls to VecRestore(), the last<br>
of which is wrong and needs to be corrected and recompiled:<br>
<br>
@@ -852,7 +852,7 @@ PetscErrorCode VecMedian(Vec Vec1, Vec Vec2, Vec<br>
Vec3, Vec VMedian)<br>
<br>
   ierr = VecRestoreArray(Vec1,&v1);CHKERRQ(ierr);<br>
   ierr = VecRestoreArray(Vec2,&v2);CHKERRQ(ierr);<br>
-  ierr = VecRestoreArray(Vec3,&v2);CHKERRQ(ierr);<br>
+  ierr = VecRestoreArray(Vec3,&v3);CHKERRQ(ierr);<br>
<br>
   if (VMedian!=Vec1 && VMedian != Vec2 && VMedian != Vec3){<br>
     ierr = VecRestoreArray(VMedian,&vmed);CHKERRQ(ierr);<br>
<br>
Jason Sarich<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Mon, Aug 11, 2014 at 9:23 AM, Khai Hong Pham <<a href="mailto:khaipham@utexas.edu">khaipham@utexas.edu</a>> wrote:<br>
> Hello,<br>
><br>
> I call TaosSolve() in my code. The solution vector is a nested and Jacobian<br>
> matrix is nested too. It shows me the error:<br>
><br>
> [0]PETSC ERROR:<br>
> ------------------------------------------------------------------------<br>
> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation,<br>
> probably memory access out of range<br>
> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger<br>
> [0]PETSC ERROR: or see<br>
> <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC</a> ERROR:<br>
> or try <a href="http://valgrind.org" target="_blank">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory<br>
> corruption errors<br>
> [1]PETSC ERROR: [0]PETSC ERROR: likely location of problem given in stack<br>
> below<br>
> [0]PETSC ERROR: ---------------------  Stack Frames<br>
> ------------------------------------<br>
> [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,<br>
> [0]PETSC ERROR:       INSTEAD the line number of the start of the function<br>
> [0]PETSC ERROR:       is given.<br>
> [0]PETSC ERROR: [0] VecRestoreArray_Nest line 731<br>
> /home/khp/bin/petsc-3.5.1/src/vec/vec/impls/nest/vecnest.c<br>
> [0]PETSC ERROR: [0] VecRestoreArray line 1656<br>
> /home/khp/bin/petsc-3.5.1/src/vec/vec/interface/rvector.c<br>
> [0]PETSC ERROR: [0] VecMedian line 806<br>
> /home/khp/bin/petsc-3.5.1/src/vec/vec/utils/projection.c<br>
> [0]PETSC ERROR: [0] TaoSolve_SSILS line 52<br>
> /home/khp/bin/petsc-3.5.1/src/tao/complementarity/impls/ssls/ssils.c<br>
> [0]PETSC ERROR: [0] TaoSolve line 171<br>
> /home/khp/bin/petsc-3.5.1/src/tao/interface/taosolver.c<br>
><br>
> I debugged with valgrind and received the following message:<br>
><br>
> ==19424== Invalid read of size 8<br>
> ==19424==    at 0x54089E4: VecRestoreArray_Nest (vecnest.c:746)<br>
> ==19424==    by 0x53F5F6F: VecRestoreArray (rvector.c:1666)<br>
> ==19424==    by 0x54BE874: VecMedian (projection.c:855)<br>
> ==19424==    by 0x6247B74: TaoSolve_SSILS (ssils.c:59)<br>
> ==19424==    by 0x620739E: TaoSolve (taosolver.c:188)<br>
> ==19424==    by 0x40491C: main (main.cpp:265)<br>
> ==19424==  Address 0x0 is not stack'd, malloc'd or (recently) free'd<br>
><br>
> It looks like the bug relates to the nested vector. Could you please give me<br>
> a hint to locate the bug? Thanks.<br>
><br>
> Khai<br>
</div></div></blockquote></div><br></div>