pcl icon indicating copy to clipboard operation
pcl copied to clipboard

pcl::visualization::RangeImageVisualizer crashes on showRangeImage() on Mac

Open brlcad opened this issue 3 years ago • 4 comments

In following the simple example at https://pointclouds.org/documentation/tutorials/range_image_visualization.html I've encountered a consistent crash on Mac inside showRangeImage(). I'm using default up-to-date PCL, Vtk, and Qt5 from Homebrew.

Context

As indicated in the tutorial, I'm trying to display points as a range image in a 2D window. Note the 3D PCLVisualizer appears to work fine, displays a window, can be rotated interactively. It's only RangeImageVisualizer::showRangeImage() that is a problem.

Current Behavior

There's a null pointer dereference happening down in Vtk, presumably the Render() context.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libvtkRenderingContext2D-9.1.1.dylib 0x000000010b6f640c vtkContextActor::RenderOverlay(vtkViewport*) + 540 1 libvtkRenderingOpenGL2-9.1.1.dylib 0x000000010bc05770 vtkOpenGLRenderer::UpdateGeometry(vtkFrameBufferObjectBase*) + 1698 2 libvtkRenderingOpenGL2-9.1.1.dylib 0x000000010bc04dbe vtkOpenGLRenderer::DeviceRender() + 526 3 libvtkRenderingCore-9.1.1.dylib 0x000000010be0e4fc vtkRenderer::Render() + 1168 4 libvtkRenderingCore-9.1.1.dylib 0x000000010be1441d vtkRendererCollection::Render() + 123 5 libvtkRenderingCore-9.1.1.dylib 0x000000010be07280 vtkRenderWindow::DoStereoRender() + 134 6 libvtkRenderingCore-9.1.1.dylib 0x000000010be0715f vtkRenderWindow::Render() + 343 7 libvtkRenderingOpenGL2-9.1.1.dylib 0x000000010bc03b8d vtkOpenGLRenderWindow::Render() + 73 8 libpcl_visualization.1.12.dylib 0x000000010951218e pcl::visualization::ImageViewer::render() + 26 9 libpcl_visualization.1.12.dylib 0x000000010951a293 pcl::visualization::RangeImageVisualizer::showRangeImage(pcl::RangeImage const&, float, float, bool) + 111 10 range_image_creation 0x00000001031f76b1 main + 881 (range_image_creation.cpp:75) 11 libdyld.dylib 0x00007fff20825f3d start + 1

To Reproduce

Tutorial steps are being followed. Commenting out the showRangeImage() line, and it runs without crashing, even displaying the second window. The rangeImage data was created as per the tutorial example.

pcl::visualization::RangeImageVisualizer range_image_widget ("Range image");
range_image_widget.showRangeImage(rangeImage);

If the latter line is commented out, the window indeed displays:

Screen Shot 2022-06-03 at 10 07 28 AM

Your Environment (please complete the following information):

  • OS: Mac 11.6.5
  • Compiler: Apple clang version 13.0.0 (clang-1300.0.29.30)
  • PCL Version: 1.12.1 (from Homebrew)

brlcad avatar Jun 03 '22 14:06 brlcad

Could this be the same problem as in https://github.com/PointCloudLibrary/pcl/issues/5159 ?

mvieth avatar Jun 03 '22 14:06 mvieth

@brlcad Have you checked whether this is the same problem?

mvieth avatar Jun 09 '22 07:06 mvieth

@mvieth It certainly appears related, but I can't say for sure. The implication would be that it's a cross-platform issue, but issue #5159 seems to point at a vtk library linkage fixing the issue and that doesn't appear to be the problem in my backtrace. I suppose there's a chance that VTK_INCLUDE_DIRS modifies some header inclusion ordering that affects subsequent runtime, so I'm testing that now and will report back.

brlcad avatar Jun 09 '22 15:06 brlcad

Calling vtk_module_autoinit() indeed appears to prevent the crash. The vtk include dirs and libs didn't have any effect nor did manually specifying a -std=* flag in case there was some std::shared_ptr compatibility issue, but the AUTOINIT includes that vtk_module_autoinit() is adding appears to get it working without the crash..

brlcad avatar Jun 09 '22 18:06 brlcad

The same issue exists when using PCL 1.12.1 (All_in_one windows installation).

Exception thrown at 0x00007FFC851AA1BD (vtkRenderingContext2D-9.1d.dll) in 3DVision.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

I was able to save the range image as png but not displaying it.

zirid avatar Jan 05 '23 02:01 zirid

Adding this section to the code solved the problem :

#include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRenderingOpenGL2); VTK_MODULE_INIT(vtkRenderingFreeType); VTK_MODULE_INIT(vtkInteractionStyle); VTK_MODULE_INIT(vtkRenderingContextOpenGL2);

zirid avatar Jan 05 '23 02:01 zirid