Segmentation fault in BoundingBoxTree2D
Dolfin (from git/master) segfaults in both interpolate()
and project()
onto a submesh. I was not able to reproduce the issue with standard submeshes (e.g., from http://fenicsproject.org/documentation/dolfin/dev/python/demo/pde/subdomains-poisson/python/documentation.html) which I why I'm also attaching the domain data.
The code for reproducing the issue is
from dolfin import *
mesh = Mesh('mydomain.xml')
domains = MeshFunction('size_t', mesh, 'mydomain_physical_region.xml')
V = FunctionSpace(mesh, 'CG', 1)
expr = Expression('x[0]')
u = project(expr, V)
submesh = SubMesh(mesh, domains, 1)
V_submesh = FunctionSpace(submesh, 'CG', 1)
# Segfault:
u_submesh = project(u, V_submesh)
# Segfault:
#u_submesh = Function(V_submesh)
#u_submesh.interpolate(u)
Comments (13)
-
-
reporter Note that the segfault doesn't occur with 1.2.0. I'll post a backtrace later.
-
reporter Backtraces:
(gdb) run main.py Starting program: /usr/bin/python main.py [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Solving linear system of size 8457 x 8457 (PETSc Krylov solver). Program received signal SIGSEGV, Segmentation fault. 0x00007ffff165647c in dolfin::BoundingBoxTree2D::less_y::operator() (this=0x7fffffffb0a0, i=4156255928, j=13639) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/BoundingBoxTree2D.h:65 65 return bi[1] + bi[3] < bj[1] + bj[3];
(gdb) backtrace #0 0x00007ffff165647c in dolfin::BoundingBoxTree2D::less_y::operator() (this=0x7fffffffb0a0, i=4156255928, j=13639) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/BoundingBoxTree2D.h:65 #1 0x00007ffff165ed3c in std::__unguarded_partition<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, unsigned int, dolfin::BoundingBoxTree2D::less_y> (__first=..., __last=..., __pivot=@0x1fd6c50: 13639, __comp=...) at /usr/include/c++/4.8/bits/stl_algo.h:2263 #2 0x00007ffff165c788 in std::__unguarded_partition_pivot<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, dolfin::BoundingBoxTree2D::less_y> (__first=..., __last=..., __comp=...) at /usr/include/c++/4.8/bits/stl_algo.h:2296 #3 0x00007ffff165ab73 in std::__introselect<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, long, dolfin::BoundingBoxTree2D::less_y> (__first=..., __nth=..., __last=..., __depth_limit=3, __comp=...) at /usr/include/c++/4.8/bits/stl_algo.h:2394 #4 0x00007ffff16594a7 in std::nth_element<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, dolfin::BoundingBoxTree2D::less_y> ( __first=..., __nth=..., __last=..., __comp=...) at /usr/include/c++/4.8/bits/stl_algo.h:5417 #5 0x00007ffff16583d3 in boost::range::nth_element<std::pair<__gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > >, __gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned int, std::allocator<unsigned int> > > >, dolfin::BoundingBoxTree2D::less_y> (rng=..., nth=..., sort_pred=...) at /usr/include/boost/range/algorithm/nth_element.hpp:66 #6 0x00007ffff1656eeb in dolfin::BoundingBoxTree2D::sort_bboxes (this=0x1ef0250, axis=1, leaf_bboxes=..., begin=..., middle=..., end=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/BoundingBoxTree2D.h:211 #7 0x00007ffff1653572 in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:308 #8 0x00007ffff165359d in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:311 #9 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #10 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #11 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #12 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #13 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.c---Type <return> to continue, or q <return> to quit--- pp:312 #14 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #15 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #16 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #17 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #18 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #19 0x00007ffff16535cb in dolfin::GenericBoundingBoxTree::_build (this=0x1ef0250, leaf_bboxes=..., begin=..., end=..., gdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:312 #20 0x00007ffff1651de9 in dolfin::GenericBoundingBoxTree::build (this=0x1ef0250, mesh=..., tdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/GenericBoundingBoxTree.cpp:78 #21 0x00007ffff1663b49 in dolfin::BoundingBoxTree::build (this=0x1b82440, mesh=..., tdim=2) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/BoundingBoxTree.cpp:71 #22 0x00007ffff1663864 in dolfin::BoundingBoxTree::build (this=0x1b82440, mesh=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/geometry/BoundingBoxTree.cpp:45 #23 0x00007ffff18cf774 in dolfin::Mesh::bounding_box_tree (this=0x1d7f4d0) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/mesh/Mesh.cpp:401 #24 0x00007ffff18401b3 in dolfin::Function::non_matching_eval (this=0x1b647b0, values=..., x=..., ufc_cell=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/function/Function.cpp:514 #25 0x00007ffff183fd30 in dolfin::Function::eval (this=0x1b647b0, values=..., x=..., ufc_cell=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/function/Function.cpp:494 #26 0x00007ffff184fff2 in dolfin::GenericFunction::evaluate (this=0x1b647b0, values=0x7fffffffc470, coordinates=0x7fffffffc480, cell=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/function/GenericFunction.cpp:185 #27 0x00007fffd3d702f6 in ffc_form_06236707c63ae02ee345885e87278c5e7db8edcb_finite_element_0::evaluate_dofs(double*, ufc::function const&, double const*, int, ufc::cell const&) const () from /home/nschloe/.instant/cache/ffc_form_06236707c63ae02ee345885e87278c5e7db8edcb/_ffc_form_06236707c63ae02ee345885e87278c5e7db8edcb.so #28 0x00007ffff185044e in dolfin::FiniteElement::evaluate_dofs (this=0x1b9b240, values=0x169bc00, f=..., vertex_coordinates=0x1b86f00, cell_orientation=0, c=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/fem/FiniteElement.h:232 #29 0x00007ffff1850246 in dolfin::GenericFunction::restrict_as_ufc_function (this=0x1b647b0, w=0x169bc00, element=..., dolfin_cell=..., ufc_cell=...) ---Type <return> to continue, or q <return> to quit--- at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/function/GenericFunction.cpp:201 #30 0x00007ffff1840e14 in dolfin::Function::restrict(double*, dolfin::FiniteElement const&, dolfin::Cell const&, ufc::cell const&) const (this=0x1b647b0, w=0x169bc00, element=..., dolfin_cell=..., ufc_cell=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/function/Function.cpp:593 #31 0x00007ffff16cfd02 in dolfin::UFC::update (this=0x7fffffffd1b0, c=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/fem/UFC.cpp:139 #32 0x00007ffff16e2938 in dolfin::SystemAssembler::cell_wise_assembly (tensors=..., ufc=..., data=..., boundary_values=..., cell_domains=0x0, exterior_facet_domains=0x0) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/fem/SystemAssembler.cpp:415 #33 0x00007ffff16e13d1 in dolfin::SystemAssembler::assemble (this=0x1baa430, A=0x1ef03f0, b=0x1ba2330, x0=0x0) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/fem/SystemAssembler.cpp:294 #34 0x00007ffff16dfac9 in dolfin::SystemAssembler::assemble (this=0x1baa430, A=..., b=...) at /home/nschloe/software/fenics/dolfin/dev/source/dolfin/fem/SystemAssembler.cpp:110 #35 0x00007fffd7a4c812 in _wrap_SystemAssembler_assemble__SWIG_0 (nobjs=3, swig_obj=0x7fffffffd5f0) at /home/nschloe/software/fenics/dolfin/dev/build/dolfin/swig/modules/fem/modulePYTHON_wrap.cxx:27469 #36 0x00007fffd7a4d6fa in _wrap_SystemAssembler_assemble (self=0x0, args=0x17f7730) at /home/nschloe/software/fenics/dolfin/dev/build/dolfin/swig/modules/fem/modulePYTHON_wrap.cxx:27784 #37 0x000000000053473a in PyEval_EvalFrameEx () #38 0x0000000000505b24 in PyEval_EvalCodeEx () #39 0x000000000052e237 in PyEval_EvalFrameEx () #40 0x0000000000505b24 in PyEval_EvalCodeEx () #41 0x000000000052e237 in PyEval_EvalFrameEx () #42 0x0000000000567cdc in PyEval_EvalCode () #43 0x0000000000451adb in ?? () #44 0x0000000000451e5b in PyRun_FileExFlags () #45 0x0000000000452394 in PyRun_SimpleFileExFlags () #46 0x0000000000453ead in Py_Main () #47 0x00007ffff7816de5 in __libc_start_main (main=0x453f6b <main>, argc=2, ubp_av=0x7fffffffdf28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdf18) at libc-start.c:260 #48 0x00000000005786be in _start ()
-- Looks like an uninitialized argunment
i
indolfin/geometry/BoundingBoxTree2D.h:65
. -
reporter - changed title to Segmentation fault in BoundingBoxTree2D
-
@nschloe Do you have Ubuntu 13.10? If yes, you should read FEniCS mailing-list. http://fenicsproject.org/pipermail/fenics/2013-November/000743.html :-P
Fix is available, see https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1246802/comments/32
Please, mark the issue as invalid.
-
reporter I'm indeed running Ubuntu 13.10, but I'm not sure if this is the fix. On dev, instead of
std::nth_element
,boost:nth_element
is used (at least on my computer). -
@nschloe Check frame 4 in your backtrace - there is
std::nth_element
call.Do you have the newest DOLFIN? @logg fixed another related bug.
-
reporter - changed status to invalid
You're right; there's both
boost:nth_element
andstd::nth_element
present. Is the one calling the other? Anyhow, upgrading to4.8.1-10ubuntu9
fixes the issue for me. -
There shouldn't be any call to std::nth_element anywhere in the code. All of them have been replaced with boost::nth_element (I hope).
-
@logg It does not seem so
r0:~/fenics/fenics-work/src/dolfin/dolfin>grep -iIHr "std::nth_element" * geometry/GenericBoundingBoxTree.cpp: std::nth_element(begin, middle, end, less_x_point(points)); geometry/GenericBoundingBoxTree.cpp: std::nth_element(begin, middle, end, less_y_point(points)); geometry/GenericBoundingBoxTree.cpp: std::nth_element(begin, middle, end, less_z_point(points)); geometry/BoundingBoxTree2D.h: std::nth_element(begin, middle, end, less_x(leaf_bboxes)); geometry/BoundingBoxTree2D.h: std::nth_element(begin, middle, end, less_y(leaf_bboxes)); geometry/BoundingBoxTree3D.h: std::nth_element(begin, middle, end, less_x_bbox(leaf_bboxes)); geometry/BoundingBoxTree3D.h: std::nth_element(begin, middle, end, less_y_bbox(leaf_bboxes)); geometry/BoundingBoxTree3D.h: std::nth_element(begin, middle, end, less_z_bbox(leaf_bboxes)); geometry/BoundingBoxTree1D.h: std::nth_element(begin, middle, end, less_x(leaf_bboxes)); geometry/GenericBoundingBoxTree.h:// std::nth_element as a workaround for a bug in STL introduced in GCC
-
reporter @logg From the backtrace, it appears that
boost::nth_element
callsstd::nth_element
. This is confirmed by looking at Boost's source, http://www.boost.org/doc/libs/1_53_0/boost/range/algorithm/nth_element.hpp. Hence, I'm not sure what the purpose of the#ifdef
ing may be. Does it really work around the bug for you? -
reporter @blechta I believe that all those explicit
std::nth_element
are#ifdef
d out. -
@nschloe You're correct!
- Log in to comment
@nschloe Can't reproduce. Can you back-trace it using debugger?