<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 26/9/2012 11:04 PM, Barry Smith
wrote:<br>
</div>
<blockquote
cite="mid:D1CDD347-2284-490E-B751-06490C5934E1@mcs.anl.gov"
type="cite">
<pre wrap="">
On Sep 26, 2012, at 4:03 PM, TAY wee-beng <a class="moz-txt-link-rfc2396E" href="mailto:zonexo@gmail.com"><zonexo@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
When I run a code in debug mode with -log_summary, there is no problem. However, in optimized mode, I encounter error "Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range"
It happens at :
call PCDestroy(pc_semi_x,ierr)
Is there any reason why it works well in debug mode but not in optimized mode?
</pre>
</blockquote>
<pre wrap="">
Memory corruption. Run first debug then optimized version under valgrind.</pre>
</blockquote>
I ran valgrind in debug mode and found:<br>
<br>
<i>==4977== Invalid read of size 4</i><i><br>
</i><i>==4977== at 0x5D4A8E7: PetscCheckPointer (petscimpl.h:219)</i><i><br>
</i><i>==4977== by 0x5D4997A: PCDestroy (precon.c:112)</i><i><br>
</i><i>==4977== by 0x5B96AB9: pcdestroy_ (preconf.c:162)</i><i><br>
</i><i>==4977== by 0x4A02E8: global_data_mp_de_ini_var_
(global.F90:1362)</i><i><br>
</i><i>==4977== by 0xD2D2E0: MAIN__ (ibm3d_high_Re.F90:1140)</i><i><br>
</i><i>==4977== by 0x4335CB: main (in
/home/wtay/Results/10/a.out)</i><i><br>
</i><i>==4977== Address 0xba21430 is 1,872 bytes inside a block of
size 2,452 free'd</i><i><br>
</i><i>==4977== at 0x4C263CF: free (vg_replace_malloc.c:427)</i><i><br>
</i><i>==4977== by 0x4FC2B84: PetscFreeAlign (mal.c:75)</i><i><br>
</i><i>==4977== by 0x4FC5BB1: PetscTrFreeDefault (mtr.c:322)</i><i><br>
</i><i>==4977== by 0x5D4A059: PCDestroy (precon.c:121)</i><i><br>
</i><i>==4977== by 0x5E30990: KSPDestroy (itfunc.c:786)</i><i><br>
</i><i>==4977== by 0x5B98FCB: kspdestroy_ (itfuncf.c:236)</i><i><br>
</i><i>==4977== by 0x4A020D: global_data_mp_de_ini_var_
(global.F90:1360)</i><i><br>
</i><i>==4977== by 0xD2D2E0: MAIN__ (ibm3d_high_Re.F90:1140)</i><i><br>
</i><i>==4977== by 0x4335CB: main (in
/home/wtay/Results/10/a.out)</i><i><br>
</i><i><br>
</i><i>[0]PETSC ERROR: --------------------- Error Message
------------------------------------</i><i><br>
</i><i>[0]PETSC ERROR: Invalid argument!</i><i><br>
</i><i>[0]PETSC ERROR: Wrong type of object: Parameter # 1!</i><i><br>
</i><i>[0]PETSC ERROR:
------------------------------------------------------------------------</i><i><br>
</i><i>[0]PETSC ERROR: Petsc Development HG revision:
3675b37c376d9b5704273c07c9eacb10845dbbe9 HG Date: Thu Jul 05
23:16:22 2012 -0500</i><i><br>
</i><i>[0]PETSC ERROR: See docs/changes/index.html for recent
updates.</i><i><br>
</i><i>[0]PETSC ERROR: See docs/faq.html for hints about trouble
shooting.</i><i><br>
</i><i>[0]PETSC ERROR: See docs/index.html for manual pages.</i><i><br>
</i><i>[0]PETSC ERROR:
------------------------------------------------------------------------</i><i><br>
</i><i>[0]PETSC ERROR: ./a.out on a petsc-3.3 named hpc12 by wtay
Thu Sep 27 10:04:56 2012</i><i><br>
</i><i>[0]PETSC ERROR: Libraries linked from
/home/wtay/Lib/petsc-3.3-dev_shared_debug/lib</i><i><br>
</i><i>[0]PETSC ERROR: Configure run at Fri Jul 6 16:18:04 2012</i><i><br>
</i><i>[0]PETSC ERROR: Configure options
--with-mpi-dir=/opt/openmpi-1.5.3/
--with-blas-lapack-dir=/opt/intelcpro-11.1.059/mkl/lib/em64t/
--with-debugging=1 --download-hypre=1
--prefix=/home/wtay/Lib/petsc-3.3-dev_shared_debug
--known-mpi-shared=1 --with-shared-libraries</i><i><br>
</i><i>[0]PETSC ERROR:
------------------------------------------------------------------------</i><i><br>
</i><i>[0]PETSC ERROR: PCDestroy() line 112 in
/home/wtay/Codes/petsc-dev/src/ksp/pc/interface/precon.c</i><i><br>
</i><i>[0]PETSC ERROR: --------------------- Error Message
------------------------------------</i><br>
<br>
Does it mean that the pc_semi_x has already been freed when I call
KSPDestroy(ksp_semi_x,ierr) earlier on? It's strange that I do not
get this error if I just run the code in debug mode without valgrind.<br>
<blockquote
cite="mid:D1CDD347-2284-490E-B751-06490C5934E1@mcs.anl.gov"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">
--
Yours sincerely,
TAY wee-beng
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<br>
</body>
</html>