PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
10.04k stars 4.62k forks source link

[kdtree] get segmentation fault when set input cloud #4137

Closed PatrickQianKun closed 4 years ago

PatrickQianKun commented 4 years ago

When use kdtree just as what example said, I got this segmentation fault. the call stack is as follows

#0  0x00007f86bf534680 in flann::any::reset (this=0x7f86b42a09f8) at /usr/include/flann/util/any.h:259
#1  0x00007f86bf53b798 in flann::any::assign<flann::flann_algorithm_t> (this=0x7f86b42a09f8, x=@0x7f86bd3f8830: flann::FLANN_INDEX_KDTREE_SINGLE) at /usr/include/flann/util/any.h:203
#2  0x00007f86bf53790f in flann::any::operator=<flann::flann_algorithm_t> (this=0x7f86b42a09f8, x=@0x7f86bd3f8830: flann::FLANN_INDEX_KDTREE_SINGLE) at /usr/include/flann/util/any.h:213
#3  0x00007f86bf5351cd in flann::KDTreeSingleIndexParams::KDTreeSingleIndexParams (this=0x7f86bd3f88c0, leaf_max_size=15, reorder=true)
    at /usr/include/flann/algorithms/kdtree_single_index.h:55
#4  0x00007f86bf53de43 in pcl::KdTreeFLANN<Plugin::Mems::Lidar::PointXYZDZALIRT, flann::L2_Simple<float> >::setInputCloud (this=0x7f86b42a07e0, cloud=..., indices=...)
    at external/pcl/pcl/kdtree/impl/kdtree_flann.hpp:123
#5  0x00007f86bf5390ff in pcl::search::KdTree<Plugin::Mems::Lidar::PointXYZDZALIRT, pcl::KdTreeFLANN<Plugin::Mems::Lidar::PointXYZDZALIRT, flann::L2_Simple<float> > >::setInputCloud (
    this=0x7f86b42a0760, cloud=..., indices=...) at external/pcl/pcl/search/impl/kdtree.hpp:81

my environment is

PatrickQianKun commented 4 years ago

the place cause the problem

#0  0x00007f86bf534680 in flann::any::reset (this=0x7f86b42a09f8) at /usr/include/flann/util/any.h:259
259             policy->static_delete(&object);

policy is a non null pointer, everything seem fine except the seg fault

kunaltyagi commented 4 years ago

PCL 1.8

Is this problem on PCL master too? Please note your distro is EOL

PatrickQianKun commented 4 years ago

@kunaltyagi I didn't test the newest version of pcl, but since the version of flann pcl used haven't updated, I believe this problem may still exist even for the pcl master.

kunaltyagi commented 4 years ago

I've confirmed this as not-a-bug in PCL. I don't see how PCL can prevent this bug.

It happens in FLANN's private implementation with no impact from any input by PCL.

https://github.com/mariusmuja/flann/blob/master/src/cpp/flann/algorithms/kdtree_single_index.h#L55

Closing the issue, but please feel free to continue discussion and searching for mitigation.