lucasw / rviz_textured_quads

RVIZ Plugin: Displays textured images in 3D space
54 stars 28 forks source link

Segmentation fault when closing RViz by quitting the application #17

Open Pietroro opened 3 years ago

Pietroro commented 3 years ago

Hi, first of all let me just say thank you for the work you have done on this, it is a very useful plugin!

We have been using the plugin for a while now and up until recently I never noticed that when exiting RViz the "intended" way by closing the window or quitting the application (instead of just Ctrl-Cing out of the rosrun or roslaunch) the display causes a segmentation fault. This only happens when an image topic actually published some images that were picked up by the textured quad display.

This is my best guess for what is causing it: Debugging via GDB pointed me to a call in RViz to SceneManager::destroyAllMovableObjects() called when closing the application and causing a segmentation fault. I have tracked it down to the delete operations of the camera display destructor.

  unsubscribe();
  delete manual_objects_;          --> "Pointer to an Ogre::ManualObject (in this case our textured plane)"
  delete decal_frustums_;
  delete textures_;
  delete mesh_nodes_;              --> "Pointer to an Ogre::SceneNode containing the mesh "

  for (size_t i = 0; i < filter_frustums_.size(); ++i)
    delete filter_frustums_[i];

  [...]

The two marked lines are the problematic ones. My best guess is that the Ogre engine (or RViz itself for that matter) has some sort of garbage collection system upon closing the app. Removing the lines and instead destroying the manual objects via SceneManager::destroySceneNode() (After checking that mesh_nodes is not NULL) has been working as a fix for now.

I have also tested the problem in a clean Ubuntu 20.04 install, publishing a simple image using image_publisher and launching your demo.launch file.