<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">What is the signature of `integrate_adaptive()`?<div class=""><br class=""></div><div class="">As Matt points out you may be copying the pointer somewhere, maybe `integrate_adaptive()` is copy-constructing its `local_calculator` argument (and hence its `local_vector`)?<div class=""><br class=""><div class=""><div class="">
<meta charset="UTF-8" class=""><div>Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)</div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Apr 1, 2022, at 10:57, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> I don't know why valgrind is not putting in line numbers but something is clearly very wrong with data structure initialization. I am not sure if it is really directly related to PETSc but somehow comes about in the C++ constructor business, which seems simple enough in your code but I don't understand. When working with MPI and C++ one must be careful that no constructors of global objects that reference MPI get called before MPI is initialized but that doesn't seem to be happening in your code.<div class=""><br class=""></div><div class=""> Sorry, I can debug it but I have no clue how to build your code it seems to use "armadillo-matrices" stuff that somehow doesn't come in through any include files or libraries. If you gave me a full makefile that builds everything I might be able to build it.<div class=""><br class=""><blockquote type="cite" class=""><div class="">On Apr 1, 2022, at 9:56 AM, Roland Richter <<a href="mailto:roland.richter@ntnu.no" class="">roland.richter@ntnu.no</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
<div class=""><p class="">Hei,</p><p class="">It defines the namespace used for armadillo-matrices. A
valgrind-log is attached for the case with removed destructor
(can't run valgrind if my program fails with a segfault).<br class="">
</p><p class="">Regards,</p><p class="">Roland<br class="">
</p>
<div class="moz-cite-prefix">Am 01.04.22 um 15:23 schrieb Barry
Smith:<br class="">
</div>
<blockquote type="cite" cite="mid:6C65CC1D-365D-43AE-B159-AFB3DCF3D4C0@petsc.dev" class="">
<div class=""><br class="">
</div>
I recommend first running with valgrind.
<div class=""><br class="">
</div>
<div class=""> I tried to build your code but got compile errors
from arma:: being unknown. Where does it come from? Is it only
in a super new version of Boost?</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Apr 1, 2022, at 6:50 AM, Roland Richter
<<a href="mailto:roland.richter@ntnu.no" class="moz-txt-link-freetext" moz-do-not-send="true">roland.richter@ntnu.no</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class=""><p class="">I re-run my code with a debug version of
PETSc, resulting in <br class="">
</p><p class=""><span style="font-family:monospace" class=""><span style="font-weight:bold;color:#ff5454;background-color:#ffffff;" class="">[0]PETSC ERROR: ---------------------
Error Message
--------------------------------------------------------------</span><span style="background-color: rgb(255, 255, 255);" class=""> </span><br class="">
[0]PETSC ERROR: Corrupt argument: <a class="moz-txt-link-freetext" href="https://petsc.org/release/faq/#valgrind" moz-do-not-send="true">https://petsc.org/release/faq/#valgrind</a>
<br class="">
[0]PETSC ERROR: Object already free: Parameter # 1 <br class="">
[0]PETSC ERROR: See <a class="moz-txt-link-freetext" href="https://petsc.org/release/faq/" moz-do-not-send="true">https://petsc.org/release/faq/</a>
for trouble shooting. <br class="">
[0]PETSC ERROR: Petsc Development GIT revision:
v3.17.0-8-gf6d6129e50 GIT Date: 2022-03-31 18:10:33
+0000 <br class="">
[0]PETSC ERROR: #1 VecGetSize() at
/home/roland/Downloads/git-files/petsc/src/vec/vec/interface/vector.c:670<br class="">
0 64 <br class="">
[0]PETSC ERROR: #2 VecDestroy() at
/home/roland/Downloads/git-files/petsc/src/vec/vec/interface/vector.c:375<br class="">
0 64 <br class="">
[0]PETSC ERROR: #3 VecGetArray() at
/home/roland/Downloads/git-files/petsc/src/vec/vec/interface/rvector.c:1780<br class="">
<br class="">
</span></p><p class="">I do not understand why it tries to access
the vector, even though it has been set to PETSC_NULL
in the previous free-call.</p><p class="">Regards,</p><p class="">Roland<br class="">
</p>
<div class="moz-cite-prefix">Am 31.03.22 um 15:50
schrieb Matthew Knepley:<br class="">
</div>
<blockquote type="cite" cite="mid:CAMYG4GnoJnQmGeCTiBZoN6QMXw5bNm+EbM0-P_DzM2S45UyxVQ@mail.gmail.com" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">On Thu, Mar 31, 2022 at 9:47
AM Roland Richter <<a href="mailto:roland.richter@ntnu.no" moz-do-not-send="true" class="moz-txt-link-freetext">roland.richter@ntnu.no</a>>
wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class=""><p class="">The backtrace is</p><p class=""><span style="font-family:monospace" class=""><span style="background-color: rgb(255, 255,
255);" class="">#0 </span><span style="color:rgb(24,24,178);background-color:rgb(255,255,255)" class="">0x00007fffeec4ba97</span><span style="background-color: rgb(255, 255,
255);" class=""> in </span><span style="color:rgb(178,104,24);background-color:rgb(255,255,255)" class="">VecGetSize_Seq</span><span style="background-color: rgb(255, 255,
255);" class=""> () from </span><span style="color:rgb(24,178,24);background-color:rgb(255,255,255)" class="">/opt/petsc/lib/libpetsc.so.3.016</span><span style="background-color: rgb(255, 255,
255);" class=""> </span><br class="">
#1 <span style="color:rgb(24,24,178);background-color:rgb(255,255,255)" class="">0x00007fffeec78f5a</span><span style="background-color: rgb(255, 255,
255);" class=""> in </span><span style="color:rgb(178,104,24);background-color:rgb(255,255,255)" class="">VecGetSize</span><span style="background-color: rgb(255, 255,
255);" class=""> () from </span><span style="color:rgb(24,178,24);background-color:rgb(255,255,255)" class="">/opt/petsc/lib/libpetsc.so.3.016</span><span style="background-color: rgb(255, 255,
255);" class=""> </span><br class="">
#2 <span style="color:rgb(24,24,178);background-color:rgb(255,255,255)" class="">0x0000000000410b73</span><span style="background-color: rgb(255, 255,
255);" class=""> in </span><span style="color:rgb(178,104,24);background-color:rgb(255,255,255)" class="">test_ts_arma_with_pure_petsc_preconfigured_clean(unsigned
long, unsigned long,
arma::Col<std::complex<doubl</span><br class="">
e> > const&,
arma::Col<std::complex<double>
>&, double, double, double) [clone
.constprop.0]<span style="background-color: rgb(255, 255,
255);" class=""> () </span><br class="">
#3 <span style="color:rgb(24,24,178);background-color:rgb(255,255,255)" class="">0x0000000000414384</span><span style="background-color: rgb(255, 255,
255);" class=""> in </span><span style="color:rgb(178,104,24);background-color:rgb(255,255,255)" class="">test_RK4_solvers_clean(unsigned
long, unsigned long, unsigned long,
bool) [clone .constprop.0]</span><span style="background-color: rgb(255, 255,
255);" class=""> () </span><br class="">
#4 <span style="color:rgb(24,24,178);background-color:rgb(255,255,255)" class="">0x0000000000405c6c</span><span style="background-color: rgb(255, 255,
255);" class=""> in </span><span style="color:rgb(178,104,24);background-color:rgb(255,255,255)" class="">main</span><span style="background-color: rgb(255, 255,
255);" class=""> ()</span></span></p>
</div>
</blockquote>
<div class="">It looks like you are passing an
invalid vector. If you compiled in debug mode,
it would tell you. I would run</div>
<div class="">in debug until my code was running
like I expect, then switch to optimized. You can
do that by using two</div>
<div class="">different PETSC_ARCH configures, and
switch at runtime with that variable.</div>
<div class=""><br class="">
</div>
<div class=""> Thanks,</div>
<div class=""><br class="">
</div>
<div class=""> Matt </div>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class=""><p class="">Regards,</p>
<div class="">Roland Richter</div>
<div class=""><br class="">
</div>
<div class="">Am 31.03.22 um 15:35 schrieb
Matthew Knepley:<br class="">
</div>
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">On Thu, Mar 31,
2022 at 9:01 AM Roland Richter <<a href="mailto:roland.richter@ntnu.no" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">roland.richter@ntnu.no</a>>
wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class=""><p class="">Hei,</p><p class="">Thanks for the idea! I
added a simple std::cout for both
constructor and destructor, and
found out that my destructor is
called multiple times, while the
constructor is called only once.
This could explain the error
(double free), but I do not know
why segfault is thrown even though
I explicitly check if the vector
has been used. Are there
explanations for that?</p>
</div>
</blockquote>
<div class="">Run with
-start_in_debugger and get the stack
trace when it faults. Right now, I
have no idea where it is faulting.</div>
<div class=""><br class="">
</div>
<div class=""> Thanks,</div>
<div class=""><br class="">
</div>
<div class=""> Matt</div>
<div class=""> <br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class=""><p class="">Regards,</p><p class="">Roland Richter<br class="">
</p>
<div class="">Am 31.03.22 um 12:14
schrieb Matthew Knepley:<br class="">
</div>
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">On Thu,
Mar 31, 2022 at 5:58 AM Roland
Richter <<a href="mailto:roland.richter@ntnu.no" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">roland.richter@ntnu.no</a>>
wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class=""><p class="">Hei,</p><p class="">For a project
I wanted to combine
boost::odeint for
timestepping and
PETSc-based vectors and
matrices for calculating
the right hand side. As
comparison for both
timing and correctness I
set up an
armadillo-based right
hand side (with the
main-function being in <b class="">main.cpp</b>,
and the test code in <b class="">test_timestepping_clean.cpp</b>)<br class="">
</p><p class="">In theory, the
code works fine, but I
have some issues with
cleaning up afterwards
in my struct <i class="">Petsc_RHS_state_clean</i>.
My initial intention was
to set up all involved
matrices and vectors
within the constructor,
and free the memory in
the destructor. To avoid
freeing vectors I have
not used I initially set
them to <i class="">PETSC_NULL</i>,
and check if this value
has been changed before
calling <i class="">VecDestroy().</i></p>
</div>
</blockquote>
<div class="">You do not need
to check. Destroy()
functions already check for
NULL.</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class=""><p class=""> However, when
doing that I get the
following error:</p><p class=""><span style="font-family:monospace" class=""><span style="background-color:
rgb(255, 255, 255);" class="">[0]PETSC
ERROR:
------------------------------------------------------------------------
</span><br class="">
[0]PETSC ERROR: Caught
signal number 11 SEGV:
Segmentation
Violation, probably
memory access out of
range <br class="">
[0]PETSC ERROR: Try
option
-start_in_debugger or
-on_error_attach_debugger <br class="">
[0]PETSC ERROR: or see
<a href="https://petsc.org/release/faq/#valgrind" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://petsc.org/release/faq/#valgrind</a>
<br class="">
[0]PETSC ERROR: or try
<a href="http://valgrind.org/" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">http://valgrind.org</a> on GNU/linux and
Apple Mac OS X to find
memory corruption
errors <br class="">
[0]PETSC ERROR:
configure using
--with-debugging=yes,
recompile, link, and
run <br class="">
[0]PETSC ERROR: to get
more information on
the crash. <br class="">
<span style="font-weight:bold;color:rgb(255,84,84);background-color:rgb(255,255,255)" class="">[0]PETSC
ERROR:
---------------------
Error Message
--------------------------------------------------------------</span></span></p><p class="">If I comment
out that code in
~Petsc_RHS_state_clean(),
the program runs, but
will use ~17 GByte of
RAM during runtime. As
the memory is not used
immediately in full, but
rather increases during
running, I assume a
memory leak somewhere.
Where does it come from,
and how can I avoid it?</p>
</div>
</blockquote>
<div class="">It must be that
your constructor is called
multiple times without
calling your destructor. I
cannot understand this code
in order</div>
<div class="">to see where
that happens, but you should
just be able to run in the
debugger and put a break
point at the creation and<br class="">
</div>
<div class="">destruction
calls.</div>
<div class=""><br class="">
</div>
<div class=""> Thanks,</div>
<div class=""><br class="">
</div>
<div class=""> Matt</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class=""><p class="">Thanks!</p><p class="">Regards,</p><p class="">Roland Richter<br class="">
</p>
<div class=""><span style="font-family:monospace" class=""></span><br class="webkit-block-placeholder">
</div>
</div>
</blockquote>
</div>
<br class="" clear="all">
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">What
most experimenters
take for granted
before they begin
their experiments
is infinitely more
interesting than
any results to
which their
experiments lead.<br class="">
-- Norbert Wiener</div>
<div class=""><br class="">
</div>
<div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" moz-do-not-send="true" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br class="" clear="all">
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">What most
experimenters take for
granted before they begin
their experiments is
infinitely more interesting
than any results to which
their experiments lead.<br class="">
-- Norbert Wiener</div>
<div class=""><br class="">
</div>
<div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" moz-do-not-send="true" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br class="" clear="all">
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">What most experimenters
take for granted before they begin
their experiments is infinitely more
interesting than any results to which
their experiments lead.<br class="">
-- Norbert Wiener</div>
<div class=""><br class="">
</div>
<div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" moz-do-not-send="true" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</blockquote>
</div>
<span id="cid:CFA2F8E1-BF13-4EF8-B340-A2FA12F963FB" class=""><out_file.txt></span></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></body></html>