Subject: [FEniCS-users] Weird error with dolfin::Function.vector().get()

From: phil marinier <[email-masked]>
Date: Wed, 19 Aug 2009 13:20:01 -0400

Ok this is a pretty random question. I am getting a segementaion violation. I tracked it to this line:

Phi.vector().get(nodes);

where
nodes is a c++ array, not a c++ std::vector. I did Phi.vector().size()
to create the array so I know the size matches up. It also blows up on
the second iteration. I think I have a problem with my Phi, which is a
dolfin::Function that I get as a solution to a VariationalProblem. My
problem is that I don't know enough about dolfin::Functions to be able
to debug one. Does anyone know of anything that could cause such a
problem? I tried plotting my Functions before it gets to that point and
it looks ok, but of course I can't do a detailed analysis unless the
vector().get() works. 

If no one has any idea about what it
could be, that's cool, I just didn't want to spend a week trying to
debug something that one of you had seen before. The actual error msg
is:

[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
http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC
ERROR: or try http://valgrind.org on linux or man libgmalloc on Apple
to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Signal received!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC
ERROR: Petsc Release Version 2.3.3, Patch 3, Fri Jun 15 16:51:25 CDT
2007 HG revision: f051789beadcd36f77fb6111d20225e26ed7cc0d
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Unknown Name on a linux-gnu named wolf by phil Wed Aug 19 13:11:20 2009
[0]PETSC ERROR: Libraries linked from /build/buildd/petsc-2.3.3/lib/linux-gnu-c-opt
[0]PETSC ERROR: Configure run at Thu Apr  2 16:27:11 2009
[0]PETSC
ERROR: Configure options --with-shared --with-dynamic
--with-debugging=0 --useThreads 0 --with-mpi-dir=/usr/lib/openmpi
--with-mpi-shared=1 --with-blas-lib=-lblas --with-lapack-lib=-llapack
--with-umfpack=1 --with-umfpack-include=/usr/include/suitesparse
--with-umfpack-lib="[/usr/lib/libumfpack.so,/usr/lib/libamd.so]"
--with-superlu=1 --with-superlu-include=/usr/include/superlu
--with-superlu-lib=/usr/lib/libsuperlu.so --with-spooles=1
--with-spooles-include=/usr/include/spooles
--with-spooles-lib=/usr/lib/libspooles.so --with-hypre=1
--with-hypre-dir=/usr --with-babel=1 --with-babel-dir=/usr
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: User provided function() line 0 in unknown directory unknown file
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD 
with errorcode 59.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
^C

Also,
I never directly communicate with petsc, so if I wanted to use the
--with-debugging=yes option, would I have to rebuild it?

Thank you for your help

Phil

---

From: "Garth N. Wells" <[email-masked]>
Date: Wed, 19 Aug 2009 18:44:11 +0100

phil marinier wrote:
> where nodes is a c++ array, not a c++ std::vector. I did 
> Phi.vector().size() to create the array so I know the size matches up. 
> It also blows up on the second iteration. 

Are you allocating memory using 'new' twice without calling delete?

Garth

I think I have a problem with
> my Phi, which is a dolfin::Function that I get as a solution to a 
> VariationalProblem. My problem is that I don't know enough about 
> dolfin::Functions to be able to debug one. Does anyone know of anything 
> that could cause such a problem? I tried plotting my Functions before it 
> gets to that point and it looks ok, but of course I can't do a detailed 
> analysis unless the vector().get() works.
> 
> If no one has any idea about what it could be, that's cool, I just 
> didn't want to spend a week trying to debug something that one of you 
> had seen before. The actual error msg is:
> 
> 
> [0]PETSC ERROR: 
> ------------------------------------------------------------------------
> [0]PETSC ERROR: or see 
> ERROR: or try http://valgrind.org on linux or man libgmalloc on Apple to 
> find memory corruption errors
> [0]PETSC ERROR: 
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 2.3.3, Patch 3, Fri Jun 15 
> 16:51:25 CDT 2007 HG revision: f051789beadcd36f77fb6111d20225e26ed7cc0d
> [0]PETSC ERROR: 
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Libraries linked from 
> /build/buildd/petsc-2.3.3/lib/linux-gnu-c-opt
> [0]PETSC ERROR: Configure options --with-shared --with-dynamic 
> [0]PETSC ERROR: 
> ------------------------------------------------------------------------
> Also, I never directly communicate with petsc, so if I wanted to use the 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> FEniCS-users mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/fenics-users

---

From: Johan Hake <[email-masked]>
Date: Wed, 19 Aug 2009 20:40:29 +0200

On Wednesday 19 August 2009 19:20:01 phil marinier wrote:
> [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
> http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Si
>gnal[0]PETSC ERROR: or try http://valgrind.org on linux or man libgmalloc on
> Apple to find memory corruption errors
> [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and
> run [0]PETSC ERROR: to get more information on the crash.
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------ [0]PETSC ERROR: Signal received!
> [0]PETSC ERROR:
> [0]PETSC ERROR: Unknown Name on a linux-gnu named wolf by phil Wed Aug 19
> 13:11:20 2009 [0]PETSC ERROR: Libraries linked from
> /build/buildd/petsc-2.3.3/lib/linux-gnu-c-opt [0]PETSC ERROR: Configure run
> at Thu Apr  2 16:27:11 2009
> [0]PETSC

You could set the linear algebra backend to uBLAS, 

  parameters("linear_algebra_backend") = "uBLAS";

then you will probably get a cleaner stack trace.

Johan