ros-industrial-attic / bezier_examples

Example usage of the bezier library:
https://github.com/ros-industrial-consortium/bezier
7 stars 6 forks source link

double free or corruption (out) #5

Open azhural opened 5 years ago

azhural commented 5 years ago

Both launches described in the readme crash with the same behaviour:

RViz reports [ERROR] [1559918877.356432458]: XML parse error [file:///home/pc/fradar_ws/src/bezier_examples/bezier_examples/meshes/ocean/ocean.ply]: XML_ERROR_PARSING_TEXT

gdb backtrace for bezier_examples_painting: #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #1 0x00007ffff534b801 in __GI_abort () at abort.c:79 #2 0x00007ffff5394897 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff54c1b9a "%s\n") at ../sysdeps/posix/libc_fatal.c:181 #3 0x00007ffff539b90a in malloc_printerr ( str=str@entry=0x7ffff54c3870 "double free or corruption (out)") at malloc.c:5350 #4 0x00007ffff53a2e75 in _int_free (have_lock=0, p=0x55555587bfd0, av=0x7ffff56f6c40 <main_arena>) at malloc.c:4278 #5 __GI___libc_free (mem=0x55555587bfe0) at malloc.c:3124 #6 0x0000555555582c40 in Eigen::internal::aligned_free (ptr=0x55555587bfe0) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:177 #7 0x0000555555583f3a in Eigen::internal::conditional_aligned_free<true> (ptr=0x55555587bfe0) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:230 #8 0x00007ffff7b4be28 in pcl::PointCloud<pcl::PointXYZ>::operator delete (ptr=0x55555587bfe0) at /home/pc/opt/install/pcl-1.8.1/include/pcl-1.8/pcl/point_cloud.h:597 #9 0x00007ffff7b65ede in pcl::PointCloud<pcl::PointXYZ>::~PointCloud (this=0x55555587bfe0, __in_chrg=<optimized out>) at /home/pc/opt/install/pcl-1.8.1/include/pcl-1.8/pcl/point_cloud.h:240 #10 0x00007ffff7b5f7a3 in boost::checked_delete<pcl::PointCloud<pcl::PointXYZ> > (x=0x55555587bfe0) at /usr/include/boost/core/checked_delete.hpp:34 #11 0x00007ffff7b86eda in boost::detail::sp_counted_impl_p<pcl::PointCloud<pcl::PointXYZ> >::dispose ( this=0x555555dd6320) at /usr/include/boost/smart_ptr/detail/sp_counted_impl.hpp:92 #12 0x00007ffff3ba8624 in pcl::VTKUtils::vtk2mesh(vtkSmartPointer<vtkPolyData> const&, pcl::PolygonMesh&) () from /home/pc/opt/install/pcl-1.8.1/lib/libpcl_surface.so.1.8 #13 0x00007ffff7b3c5f7 in Bezier::estimateGlobalMeshNormal (this=0x55555587b1e0, polydata=..., mesh_normal=..., iterations=2000) at /home/pc/fradar_ws/src/bezier/src/bezier_library.cpp:205 #14 0x00007ffff7b3d1f5 in Bezier::estimateSlicingOrientation (this=0x55555587b1e0, polydata=..., mesh_normal=..., orientation=...) at /home/pc/fradar_ws/src/bezier/src/bezier_library.cpp:269 #15 0x00007ffff7815042 in BezierPainting::generateTrajectory[abi:cxx11](std::vector<Eigen::Transform<double, 3, 1, 0>, Eigen::aligned_allocator<Eigen::Transform<double, 3, 1, 0> > >&, std::vector<bool, std::allocator<bool> >&, bool) (this=0x55555587b1e0, trajectory=std::vector of length 0, capacity 0, is_grinding_pose=std::vector<bool> of length 0, capacity 0, display_markers=true) at /home/pc/fradar_ws/src/bezier/src/painting.cpp:57 #16 0x000055555558011d in main (argc=1, argv=0x7fffffffd4d8) at /home/pc/fradar_ws/src/bezier_examples/bezier_examples/src/painting.cpp:94

VTK version is 7.1.1, PCL version is 1.8.1 and built using the same VTK version.

Since the .ply files looked really messy when opening them in vim (while the header is readable), I tried rebuilding them using the supplied .blend files. Unfortunately that did not help.

Any help would be appreciated. Thank you.

Edit: Using Ubuntu 18.04 with Melodic.

VictorLamoine commented 5 years ago

Thanks for the backtrace! The PLY meshes are in binary format so it's ok they look messy if you open them as text. Open them with Meshlab and you will see they are not malformed.

The problem lies in pcl::VTKUtils::vtk2mesh (in bezier_library) but I'm not sure why it crashes. Especially given the fact you have compiled PCL using the VTK version compiled from source.

DanielSchimpf commented 5 years ago

Hello,

I am running into the same issue. Tried different .ply files. @VictorLamoine would any other information help you find a solution or the cause?

Thanks!

VictorLamoine commented 5 years ago

Hi there,

I think (but I'm not sure yet!) the problem lies in PCL so the best thing to do is to try to reproduce the problem with PCL by writing a program that uses pcl::VTKUtils::vtk2mesh. If the crash happens also try compiling PCL latest git and compiling your test against this newest version, maybe the problem is already solved.

If you are able to reproduce the problem with PCL latest git then we'll open an issue in PCL to solve the problem. I can do these tests but not right now (probably next week), so please let me know if you have some time to do it.

VictorLamoine commented 5 years ago

cube.ply is a cube exported from Blender.

#include <iostream>
#include <vtkPLYReader.h>
#include <pcl/surface/vtk_smoothing/vtk_utils.h>

int main(int, char **)
{
  vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
  vtkSmartPointer<vtkPolyData> vtk_mesh = vtkSmartPointer<vtkPolyData>::New();
  reader->SetFileName("cube.ply");
  reader->SetOutput(vtk_mesh);

  std::cout << "Number of points = " << vtk_mesh->GetNumberOfPoints() << std::endl;
  pcl::PolygonMesh pcl_mesh;
  pcl::VTKUtils::vtk2mesh(vtk_mesh, pcl_mesh);
  return 0;
}
Number of points = 0

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff77b622e in vtkPoints::GetNumberOfPoints (this=0x0) at /usr/local/include/vtk-8.2/vtkPoints.h:126
126   vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
(gdb) bt
#0  0x00007ffff77b622e in vtkPoints::GetNumberOfPoints (this=0x0) at /usr/local/include/vtk-8.2/vtkPoints.h:126
#1  0x00007ffff77b4e1e in pcl::VTKUtils::vtk2mesh (poly_data=..., mesh=...) at /home/victor/libraries/pcl/src/surface/src/vtk_smoothing/vtk_utils.cpp:98
#2  0x00005555555583c2 in main ()

https://github.com/PointCloudLibrary/pcl/blob/master/surface/src/vtk_smoothing/vtk_utils.cpp#L98

azhural commented 5 years ago

Sorry, I was quite busy. Any update on this issue? I couldn't find any issues/PRs on PCL or VTK that looked related.

VictorLamoine commented 5 years ago

I don't have time to dig further sorry.

phuicy commented 3 years ago

Interestingly, running PCL 1.9.1 in debug, and VTK 8.2 in release

Solves this problem.