Skip to content

Instantly share code, notes, and snippets.

@Harold2017
Last active March 1, 2022 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Harold2017/91f6d1f087a4a60c0d310a7f7a4110c8 to your computer and use it in GitHub Desktop.
Save Harold2017/91f6d1f087a4a60c0d310a7f7a4110c8 to your computer and use it in GitHub Desktop.
PCL seg fault on Linux due to Eigen3 aligned_free
Processing camera 1 of 26.

Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x55041) at malloc.c:3102
3102    malloc.c: No such file or directory.

(gdb) bt full
#0  __GI___libc_free (mem=0x55041) at malloc.c:3102
        ar_ptr = <optimized out>
        p = <optimized out>
        hook = 0x0
#1  0x00000000004147e2 in Eigen::internal::handmade_aligned_free (ptr=0x900820) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:98
No locals.
#2  0x000000000041483e in Eigen::internal::aligned_free (ptr=0x900820) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:179
No locals.
#3  0x000000000042e08e in Eigen::aligned_allocator<pcl::PointXYZ>::deallocate (this=0x8aa760, p=0x900820)
    at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:763
No locals.
#4  0x0000000000428b16 in std::allocator_traits<Eigen::aligned_allocator<pcl::PointXYZ> >::deallocate (__a=..., __p=0x900820, __n=21763)
    at /usr/include/c++/9/bits/alloc_traits.h:332
No locals.
#5  0x0000000000421b5a in std::_Vector_base<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> >::_M_deallocate (this=0x8aa760, 
    __p=0x900820, __n=21763) at /usr/include/c++/9/bits/stl_vector.h:351
No locals.
#6  0x000000000041c488 in std::_Vector_base<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> >::~_Vector_base (this=0x8aa760, 
    __in_chrg=<optimized out>) at /usr/include/c++/9/bits/stl_vector.h:332
No locals.
#7  0x000000000041c4d9 in std::vector<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> >::~vector (this=0x8aa760, 
    __in_chrg=<optimized out>) at /usr/include/c++/9/bits/stl_vector.h:680
No locals.
#8  0x000000000042e11e in pcl::PointCloud<pcl::PointXYZ>::~PointCloud (this=0x8aa730, __in_chrg=<optimized out>)
    at /usr/include/pcl-1.10/pcl/point_cloud.h:180
No locals.
#9  0x000000000042e14b in boost::checked_delete<pcl::PointCloud<pcl::PointXYZ> > (x=0x8aa730) at /usr/include/boost/core/checked_delete.hpp:36
No locals.
#10 0x00000000004440f0 in boost::detail::sp_counted_impl_p<pcl::PointCloud<pcl::PointXYZ> >::dispose (this=0x8a93a0)
    at /usr/include/boost/smart_ptr/detail/sp_counted_impl.hpp:93
No locals.
#11 0x00007ffff4a5a36a in boost::detail::sp_counted_base::release() () from /usr/lib/x86_64-linux-gnu/libpcl_surface.so.1.10
No symbol table info available.
#12 0x00007ffff5035483 in pcl::TextureMapping<pcl::PointXYZ>::textureMeshwithMultipleCameras(pcl::TextureMesh&, std::vector<pcl::texture_mapping::Camera, Eigen::aligned_allocator<pcl::texture_mapping::Camera> > const&) () from /usr/lib/x86_64-linux-gnu/libpcl_surface.so.1.10
No symbol table info available.
(gdb) where
#0  __GI___libc_free (mem=0x55041) at malloc.c:3102
#1  0x00000000004147e2 in Eigen::internal::handmade_aligned_free (ptr=0x901050) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:98
#2  0x000000000041483e in Eigen::internal::aligned_free (ptr=0x901050) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:179
#3  0x000000000042e08e in Eigen::aligned_allocator<pcl::PointXYZ>::deallocate (this=0x8a95d0, p=0x901050)
    at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:763
#4  0x0000000000428b16 in std::allocator_traits<Eigen::aligned_allocator<pcl::PointXYZ> >::deallocate (__a=..., __p=0x901050, __n=21763)
    at /usr/include/c++/9/bits/alloc_traits.h:332
#5  0x0000000000421b5a in std::_Vector_base<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> >::_M_deallocate (this=0x8a95d0, 
    __p=0x901050, __n=21763) at /usr/include/c++/9/bits/stl_vector.h:351
#6  0x000000000041c488 in std::_Vector_base<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> >::~_Vector_base (this=0x8a95d0, 
    __in_chrg=<optimized out>) at /usr/include/c++/9/bits/stl_vector.h:332
#7  0x000000000041c4d9 in std::vector<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> >::~vector (this=0x8a95d0, 
    __in_chrg=<optimized out>) at /usr/include/c++/9/bits/stl_vector.h:680
#8  0x000000000042e11e in pcl::PointCloud<pcl::PointXYZ>::~PointCloud (this=0x8a95a0, __in_chrg=<optimized out>) at /usr/include/pcl-1.10/pcl/point_cloud.h:180
#9  0x000000000042e14b in boost::checked_delete<pcl::PointCloud<pcl::PointXYZ> > (x=0x8a95a0) at /usr/include/boost/core/checked_delete.hpp:36
#10 0x00000000004440f0 in boost::detail::sp_counted_impl_p<pcl::PointCloud<pcl::PointXYZ> >::dispose (this=0x8a9640) at /usr/include/boost/smart_ptr/detail/sp_counted_impl.hpp:93
#11 0x00007ffff4a5a36a in boost::detail::sp_counted_base::release() () from /usr/lib/x86_64-linux-gnu/libpcl_surface.so.1.10
#12 0x00007ffff5035483 in pcl::TextureMapping<pcl::PointXYZ>::textureMeshwithMultipleCameras(pcl::TextureMesh&, std::vector<pcl::texture_mapping::Camera, Eigen::aligned_allocator<pcl::texture_mapping::Camera> > const&) () from /usr/lib/x86_64-linux-gnu/libpcl_surface.so.1.10
#13 0x00000000004123be in main (argc=4, argv=0x7fffffffdb88) at /home/don/Desktop/Harold/source/without_vtk.cpp:161

The bug place is located at Eigen3 aligned_free, which caused by the SIMD.

MSVC dist requires AVX enabled but Linux does NOT!

Solution

Remove -march=native or other SSE/AVX compile options on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment