Skip to content

[ndt/filter] call pcl::NormalDistributionsTransform::setInputTarget twice got segfault #4944

@marf-cn

Description

@marf-cn

Describe the bug

A clear and concise description of what the bug is.
got segfault when calling pcl::NormalDistributionsTransform::setInputTarget second time.

Context

What are you trying to accomplish? Providing context helps us come up with a solution that is most useful in the real world

Expected behavior

A clear and concise description of what you expected to happen.

Current Behavior

What happens instead of the expected behavior?

To Reproduce

chang the map and call
pcl::NormalDistributionsTransform::setInputTarget
again
static pcl::NormalDistributionsTransform<pcl::PointXYZI, pcl::PointXYZI> ndt;
.......
ndt.setTransformationEpsilon(trans_eps);
ndt.setStepSize(step_size);
ndt.setResolution(ndt_res);
ndt.setMaximumIterations(max_iter);
ndt.setInputSource(filtered_scan_ptr);
ndt.setInputTarget(map_ptr1);
ndt.align(*output_cloud, init_guess);
....
ndt.setTransformationEpsilon(trans_eps);
ndt.setStepSize(step_size);
ndt.setResolution(ndt_res);
ndt.setMaximumIterations(max_iter);
ndt.setInputSource(filtered_scan_ptr);
ndt.setInputTarget(map_ptr2); //got segfault

Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. A reproducible example helps to provide faster answers.

Screenshots/Code snippets
#0 0x00007fffe8e2ea6d in free () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00005555555ca47f in Eigen::internal::handmade_aligned_free(void*) ()
#2 0x00005555555ca4db in Eigen::internal::aligned_free(void*) ()
#3 0x00005555555ccd7d in void Eigen::internal::conditional_aligned_free(void*) ()
#4 0x00005555555d2420 in void Eigen::internal::conditional_aligned_delete_auto<float, true>(float*, unsigned long) ()
#5 0x00005555555cd19d in Eigen::DenseStorage<float, -1, -1, 1, 0>::~DenseStorage() ()
#6 0x00005555555cb578 in Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >::~PlainObjectBase() ()
#7 0x00005555555cb594 in Eigen::Matrix<float, -1, 1, 0, -1, 1>::~Matrix() ()
#8 0x00005555555f145c in pcl::VoxelGridCovariancepcl::PointXYZ::Leaf::~Leaf() ()
#9 0x00005555555f147c in std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>::~pair() ()
#10 0x00005555555f149c in void __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::destroy<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >(std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>) ()
#11 0x00005555555ecc6f in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > > >::destroy<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >(std::allocator<std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >&, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>
) ()
#12 0x00005555555e882d in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >) ()
#13 0x00005555555e355d in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_drop_node(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >
) ()
#14 0x00005555555dafea in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >) ()
#15 0x00005555555dafc7 in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >
) ()
#16 0x00005555555dafc7 in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >) ()
#17 0x00005555555dafc7 in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >
) ()
#18 0x00005555555dafc7 in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >) ()
#19 0x00005555555dafc7 in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >
) ()
#20 0x00005555555dafc7 in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >) ()
#21 0x00005555555dafc7 in std::_Rb_tree<unsigned long, std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf>, std::_Select1st<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >, std::less, std::allocator<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned long const, pcl::VoxelGridCovariancepcl::PointXYZ::Leaf> >
) ()
In order to help explain your problem, please consider adding

  • screenshots of the GUI issues
  • code snippets: syntax for code with correct language highlights

Your Environment (please complete the following information):

  • OS: [e.g. Ubuntu 18.04]
  • Compiler: [:eg GCC 8.1]
  • PCL Version [e.g. 1.10, HEAD]

Possible Solution
try putting PCL_MAKE_ALIGNED_OPERATOR_NEW in VoxelGridCovariance

class VoxelGridCovariance : public VoxelGrid
{
// public:
// PCL_MAKE_ALIGNED_OPERATOR_NEW
...
Not obligatory, but suggest a fix/reason for the bug. Feel free to create a PR if you feel comfortable.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions