Jan,

Thanks for all your suggestions. For future reference I'd like to give an
update on solving the issue. The code in BoundingBoxTree3D.h that segfaults
is called through std::nth_element function, so I guess that using GCC
4.8.2 my FEniCS installation was susceptible to this bug of the standard
library https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800

I recompiled everything (with some extra efforts) with GCC 5.2 and the
problem disappeared.  Thanks very much for the hints!

Best,
Paolo

On Mon, Oct 26, 2015 at 12:57 PM, Jan Blechta <[email protected]>
wrote:

> On Mon, 26 Oct 2015 10:56:43 -0400
> Paolo Di Achille <[email protected]> wrote:
>
> > Jan,
> >
> > Thanks very much for looking into this. The output for your code is
> > 4294967295
>
> This is 32-bit uint. Are you sure you've compiled the code with the same
> compiler and C/C++ headers as DOLFIN is compiled with?
>
> >
> > And sorry for the broken link, the following should work instead
> > https://yale.box.com/s/j20x0loaclio1wsjzonv7khhf3iov2lg
> > For this mesh, the value of mesh.num_entities(3) is 888780.
>
> I cannot reproduce the problem with the mesh. You may try digging more
> deeply into the problem using debugger.
>
> Jan
>
> >
> > Best,
> > Paolo
> >
> > On Mon, Oct 26, 2015 at 9:50 AM, Jan Blechta
> > <[email protected]> wrote:
> >
> > > The link to the meshfile does not work. Can you provide a mesh
> > > again?
> > >
> > > There's a conversion from size_t to uint in [1], which could
> > > overflow if you have 16-bit uint. What's the output of
> > > //----------------------------------------------------
> > > echo "#include <limits>
> > > #include <iostream>
> > >
> > > int main() {
> > >   std::cout << std::numeric_limits<unsigned int>::max() <<
> > > std::endl;
> > >
> > >   return 0;
> > > }
> > > " | c++ -std=c++11 -xc++ - && ./a.out
> > > //----------------------------------------------------
> > >
> > > [1]
> > >
> > >
> https://bitbucket.org/fenics-project/dolfin/src/8ad7544e62714eaf561e52880925d3713756f3c0/dolfin/geometry/GenericBoundingBoxTree.cpp?at=master&fileviewer=file-view-default#GenericBoundingBoxTree.cpp-93
> > >
> > > Jan
> > >
> > >
> > > On Sat, 24 Oct 2015 20:13:41 -0400
> > > Paolo Di Achille <[email protected]> wrote:
> > >
> > > > Jan,
> > > >
> > > > Thanks very much for the suggestions. I used the debugger using
> > > > your instructions and below you can find the first five frames of
> > > > the backtrace
> > > >
> > > > #0  0x00002aaabb908d34 in
> > > > dolfin::BoundingBoxTree3D::less_z_bbox::operator()(unsigned int,
> > > > unsigned int) ()
> > > >     at
> > > /home/fas/pd/src/dolfin-1.6.0/dolfin/geometry/BoundingBoxTree3D.h:76
> > > >
> > > > #1  0x00002aaabb90f38a in __gnu_cxx::__normal_iterator<unsigned
> > > > int*, std::vector<unsigned int, std::allocator<unsigned int> > >
> > > > std::__unguarded_partition<__gnu_cxx::__normal_iterator<unsigned
> > > > int*, std::vector<unsigned int, std::allocator<unsigned int> > >,
> > > > unsigned int,
> > > >
> > >
> dolfin::BoundingBoxTree3D::less_z_bbox>(__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> > >, unsigned int const&,
> > > > dolfin::BoundingBoxTree3D::less_z_bbox) ()
> > > > at
> /gpfs/apps/hpc/Langs/GCC/4.8.2/include/c++/4.8.2/bits/stl_algo.h:2263
> > > >
> > > > #2  0x00002aaabb90c89d in __gnu_cxx::__normal_iterator<unsigned
> > > > int*, std::vector<unsigned int, std::allocator<unsigned int> > >
> > > >
> std::__unguarded_partition_pivot<__gnu_cxx::__normal_iterator<unsigned
> > > > int*, std::vector<unsigned int, std::allocator<unsigned int> > >,
> > > >
> > >
> dolfin::BoundingBoxTree3D::less_z_bbox>(__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::BoundingBoxTree3D::less_z_bbox) ()
> > > > at
> /gpfs/apps/hpc/Langs/GCC/4.8.2/include/c++/4.8.2/bits/stl_algo.h:2296
> > > >
> > > > #3  0x00002aaabb90afc8 in void
> > > > std::__introselect<__gnu_cxx::__normal_iterator<unsigned int*,
> > > > std::vector<unsigned int, std::allocator<unsigned int> > >, long,
> > > >
> > >
> dolfin::BoundingBoxTree3D::less_z_bbox>(__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> > >,
> > > > __gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned
> > > > int, std::allocator<unsigned int> > >, long,
> > > > dolfin::BoundingBoxTree3D::less_z_bbox) ()
> > > > at
> /gpfs/apps/hpc/Langs/GCC/4.8.2/include/c++/4.8.2/bits/stl_algo.h:2394
> > > >
> > > > #4  0x00002aaabb90a326 in void
> > > > std::nth_element<__gnu_cxx::__normal_iterator<unsigned int*,
> > > > std::vector<unsigned int, std::allocator<unsigned int> > >,
> > > >
> > >
> dolfin::BoundingBoxTree3D::less_z_bbox>(__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> > >,
> > > > __gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned
> > > > int, std::allocator<unsigned int> > >,
> > > > dolfin::BoundingBoxTree3D::less_z_bbox) ()
> > > > at
> /gpfs/apps/hpc/Langs/GCC/4.8.2/include/c++/4.8.2/bits/stl_algo.h:5417
> > > >
> > > > #5  0x00002aaabb909bb2 in
> > > > dolfin::BoundingBoxTree3D::sort_bboxes(unsigned long,
> > > > std::vector<double, std::allocator<double> > const&,
> > > > __gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned
> > > > int, std::allocator<unsigned int> > > const&,
> > > > __gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned
> > > > int, std::allocator<unsigned int> > > const&,
> > > > __gnu_cxx::__normal_iterator<unsigned int*, std::vector<unsigned
> > > > int, std::allocator<unsigned int> > > const&) ()
> > > > at
> /home/fas/pd/src/dolfin-1.6.0/dolfin/geometry/BoundingBoxTree3D.h:249
> > > >
> > > > The segfault seems to arise at line 76 as reported below, inside
> > > > struct less_z_bbox of BoundingBoxTree3D.h
> > > >
> > > > | 72            inline bool operator()(unsigned int i, unsigned
> > > > int j)
> > > >
> > > > | 73
> > > > {
> > > >
> > > > | 74              const double* bi = bboxes.data() +
> > > > 6*i;
> > > >
> > > > | 75              const double* bj = bboxes.data() +
> > > > 6*j;
> > > >
> > > > | 76              return bi[2] + bi[5] < bj[2] +
> > > > bj[5];
> > > >
> > > > | 77            }
> > > >
> > > > when the integer 'i'  gets a much larger value than it gets in
> > > > many previous successful calls. Also, I was not able to reproduce
> > > > the segmentation fault with smaller mesh files, but the error
> > > > consistently occurs for relatively large meshes (~500 000
> > > > elements), like the one I uploaded at this link:
> > > >
> > > > https://yale.box.com/s/yyls3w8j2j7refryywy9yj79pvalhjyd
> > > >
> > > > Please let me know if I can any provide further information, and
> > > > again thanks very much!
> > > >
> > > > Best,
> > > > Paolo
> > > >
> > > >
> > > >
> > > >
> > > > On Sat, Oct 24, 2015 at 12:49 PM, Jan Blechta
> > > > <[email protected]> wrote:
> > > >
> > > > > You can try debugger
> > > > >
> > > > > gdb -ex r -args python script.py
> > > > > <program terminates with segfault>
> > > > > (GDB) bt
> > > > > <stack trace>
> > > > > (GDB) f <suspicious_frame>
> > > > > (GDB) w
> > > > > <code in question>
> > > > > (GDB) p <suspicious_pointer>
> > > > >
> > > > > Can you also provide us the mesh?
> > > > >
> > > > > Jan
> > > > >
> > > > >
> > > > > On Sat, 24 Oct 2015 11:24:23 -0400
> > > > > Paolo Di Achille <[email protected]> wrote:
> > > > >
> > > > > > Dear FEniCS users and developers,
> > > > > >
> > > > > > I don't seem to be able to build the BoundingBoxTree of a
> > > > > > correctly loaded mesh using a recent installation from source
> > > > > > of FEniCS 1.6.0 on a local cluster. The following minimal code
> > > > > > results in a segfault error
> > > > > >
> > > > > > >>> from dolfin import *
> > > > > > >>> mm = Mesh('mesh.xml')
> > > > > > >>> mm.bounding_box_tree().build(mm)
> > > > > >
> > > > > > Surprisingly, I can use with no apparent issues other features
> > > > > > that do not explicitly require building a tree (e.g. solving a
> > > > > > problem in parallel, I/O of XDMF files), but the software
> > > > > > fails, probably for the same reason, when I need to evaluate
> > > > > > a function at a point of given coordinates. Likely, I must
> > > > > > have missed some installation requirements and any pointers
> > > > > > or suggestions would be highly appreciated.
> > > > > >
> > > > > > My current installation of FEniCS was built against
> > > > > > OpenMPI-1.8.1, Python-2.7.6, Swig-3.0.7, Boost-1.59.0,
> > > > > > HDF5-1.8.10, VTK-5.10.1, Scotch-6.0.4, Petsc-3.6.2 using
> > > > > > GCC-4.8.2 and Cmake-3.3.2. Also no error was output during
> > > > > > compilation and linking.
> > > > > >
> > > > > > Thanks very much! Best,
> > > > > > Paolo
> > > > >
> > > > >
> > >
> > >
>
>
_______________________________________________
fenics-support mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics-support

Reply via email to