Robotics StackExchange | Archived questions

PCL segmentation fault

I am using ROS kinetic and I have PCL-1.9.1 installed on my computer. For the very same package, when compiled in different catkin workspaces, it performs differently.

To reproduce the error, you need a .pcd file and change the path and file name accordingly in the code.

At ~/catkin_ws

yiying@matebook-x:~/catkin_ws$ ./devel/lib/cylinder_segmentation/cylinder_segmentation 
Failed to find match for field 'rgb'.
PointCloud before filtering has: 20238 data points.
Cylinder coefficients: header: 
seq: 0 stamp: 0 frame_id: 
values[]
  values[0]:   -0.877246
  values[1]:   0.338439
  values[2]:   -0.217082
  values[3]:   0.885413
  values[4]:   -0.158791
  values[5]:   0.43684
  values[6]:   0.0644546

While at ~/fetchit_ws, it has segmentation fault

yiying@matebook-x:~/fetchit_ws$ gdb ./devel/lib/cylinder_segmentation/cylinder_segmentation 
GNU gdb (Ubuntu 8.2-0ubuntu1~16.04.1) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./devel/lib/cylinder_segmentation/cylinder_segmentation...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/yiying/fetchit_ws/devel/lib/cylinder_segmentation/cylinder_segmentation 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
PointCloud before filtering has: 20238 data points.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5901fc0 in void Eigen::internal::call_assignment_no_alias<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::internal::assign_op<float> >(Eigen::Matrix<float, -1, -1, 0, -1, -1>&, Eigen::Matrix<float, -1, -1, 0, -1, -1> const&, Eigen::internal::assign_op<float> const&)
    () from /usr/local/lib/libpcl_features.so.1.9
(gdb) bt
#0  0x00007ffff5901fc0 in void Eigen::internal::call_assignment_no_alias<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::internal::assign_op<float> >(Eigen::Matrix<float, -1, -1, 0, -1, -1>&, Eigen::Matrix<float, -1, -1, 0, -1, -1> const&, Eigen::internal::assign_op<float> const&) () from /usr/local/lib/libpcl_features.so.1.9
#1  0x00007fffed1d3474 in Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> >::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::EigenBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&) ()
   from /usr/local/lib/libpcl_sample_consensus.so.1.9
#2  0x00007fffed375740 in Eigen::LevenbergMarquardt<Eigen::NumericalDiff<pcl::SampleConsensusModelCylinder<pcl::PointXYZRGB, pcl::Normal>::OptimizationFunctor, (Eigen::NumericalDiffMode)0>, float>::minimizeOneStep(Eigen::Matrix<float, -1, 1, 0, -1, 1>&) () from /usr/local/lib/libpcl_sample_consensus.so.1.9
#3  0x00007fffed3764ab in pcl::SampleConsensusModelCylinder<pcl::PointXYZRGB, pcl::Normal>::optimizeModelCoefficients(std::vector<int, std::allocator<int> > const&, Eigen::Matrix<float, -1, 1, 0, -1, 1> const&, Eigen::Matrix<float, -1, 1, 0, -1, 1>&) const () from /usr/local/lib/libpcl_sample_consensus.so.1.9
#4  0x00007ffff42e9eed in pcl::SACSegmentation<pcl::PointXYZRGB>::segment(pcl::PointIndices&, pcl::ModelCoefficients&) ()
   from /usr/local/lib/libpcl_segmentation.so.1.9
#5  0x0000000000437d4a in main ()
(gdb) 

Catkin workspace configuration:

yiying@matebook-x:~/catkin_ws$ catkin config
--------------------------------------------------------------------------
Profile:                     default
Extending:          [cached] /home/yiying/catkin_ws/devel:/opt/ros/kinetic
Workspace:                   /home/yiying/catkin_ws
--------------------------------------------------------------------------
Build Space:        [exists] /home/yiying/catkin_ws/build
Devel Space:        [exists] /home/yiying/catkin_ws/devel
Install Space:      [unused] /home/yiying/catkin_ws/install
Log Space:         [missing] /home/yiying/catkin_ws/logs
Source Space:       [exists] /home/yiying/catkin_ws/src
DESTDIR:            [unused] None
--------------------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
--------------------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
--------------------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
--------------------------------------------------------------------------


--------------------------------------------------------------------------
WARNING: Your current environment's CMAKE_PREFIX_PATH is different from
the cached CMAKE_PREFIX_PATH used the last time this workspace was built.

If you want to use a different CMAKE_PREFIX_PATH you should call `catkin
clean` to remove all references to the previous CMAKE_PREFIX_PATH.

Cached CMAKE_PREFIX_PATH:
    /home/yiying/catkin_ws/devel:/opt/ros/kinetic
Current CMAKE_PREFIX_PATH:
    /home/yiying/fetchit_ws/devel:/home/yiying/catkin_ws/devel:/opt/ros/kinetic
--------------------------------------------------------------------------

The other:

yiying@matebook-x:~/fetchit_ws$ catkin config
--------------------------------------------------------------------------
Profile:                     default
Extending:          [cached] /home/yiying/catkin_ws/devel:/opt/ros/kinetic
Workspace:                   /home/yiying/fetchit_ws
--------------------------------------------------------------------------
Build Space:        [exists] /home/yiying/fetchit_ws/build
Devel Space:        [exists] /home/yiying/fetchit_ws/devel
Install Space:      [unused] /home/yiying/fetchit_ws/install
Log Space:         [missing] /home/yiying/fetchit_ws/logs
Source Space:       [exists] /home/yiying/fetchit_ws/src
DESTDIR:            [unused] None
--------------------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
--------------------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
--------------------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
--------------------------------------------------------------------------
Workspace configuration appears valid.
--------------------------------------------------------------------------

Asked by yiying on 2020-08-14 11:54:18 UTC

Comments

@stevemacenski This is not PCL sepcific. Please reopen the question.

If compiled as C++ project, it runs without any problem. The problem I have is clearly ROS related.

Asked by yiying on 2020-08-14 21:45:09 UTC

It is, but it also isn't.

The most likely explanation is that you have multiple different versions of PCL, and the ROS binaries (ie: pcl_ros, pcl_conversions, etc) have been linked against one version, while you are trying to use a different version in your own nodes.

If your own nodes then also link against libraries from pcl_ros et al., just about the first thing you'll run into are SEGFAULTs.

You cannot link against two different versions of the same library. That cannot work.

You will have to make sure only a single version of PCL gets linked. Directly, as well as transitively.

And the reason I write it isn't a ROS problem is because this is not ROS specific. You just happen to run into it with PCL and a ROS node, but this is a general problem which has to do with how C++ binaries are constructed.

Asked by gvdhoorn on 2020-08-15 04:01:54 UTC

@gvdhoorn Thanks for your comment. You made a good point about two versions of PCL and linking issue. I do have PCL 1.9.1 installed and uses PCL 1.9.1, pcl_ros and pcl_conversions in my node.

What I don't understand is why one identical package (link given in description) will lead to two different results. The same error should appears no matter where the package is compiled, right? It doesn't. I suspect it has to do with how the catkin workspace is set up/configured, but looking at both config, I cannot see what it is that leads to the problem.

Asked by yiying on 2020-08-15 13:03:03 UTC

@gvdhoorn Care to answer my question?

Asked by yiying on 2020-08-23 17:25:27 UTC

Answers

For those who are still curious about this problem, I have conducted research on it. In my project, I encountered a Segmentation Fault in PCL due to two specific CPP compile flags. However, after commenting out these flags, PCL works perfectly fine.

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DONT_VECTORIZE -DEIGEN_MAX_ALIGN_BYTES=0")

Asked by Ruijie on 2023-07-14 13:14:10 UTC

Comments