Skip to content
This repository has been archived by the owner on Nov 13, 2017. It is now read-only.

fixed segfault on shutdown #614

Merged
merged 1 commit into from
Oct 1, 2015
Merged

fixed segfault on shutdown #614

merged 1 commit into from
Oct 1, 2015

Conversation

rhaschke
Copy link
Contributor

rviz always crashed on shutdown with MotionPlanning display loaded.
Reason was, that Kinematics pointers were destroyed after the underlying library was unloaded.

Use of pluginlib's createUnmanagedInstance() is strongly discouraged:
http://wiki.ros.org/class_loader#Understanding_Loading_and_Unloading

There are several other locations in the source, where the discouraged createUnmanagedInstance() is used!

use of pluginlib's createUnmanagedInstance() is strongly discouraged:
http://wiki.ros.org/class_loader#Understanding_Loading_and_Unloading
here, the kinematics plugin libs were unloaded before destruction of corresponding pointers
@rhaschke
Copy link
Contributor Author

The patch actually replaces the inconspicuous segfault message with a shiny warning message from class_loader, that the order of pointer releases is wrong - which was exactly the reason for the segfault.

Digging a little bit deeper, I found the underlying reason:
The SharedStorage maintains a static storage of RobotModelLoaders, which gets freed only very late in the stutdown process. On the other hand, the PlanningSceneMonitor directly allocates a RobotModelLoader first. When releasing this RobotModelLoader at destruction time of the PlanningSceneMonitor, the kinematics plugin lib will be unloaded too.
I guess, that's an issue in the class_loader lib, which should be aware of several independent resources accessing the same lib.

@rhaschke
Copy link
Contributor Author

Digging even further, I believe, that MultiLibraryClassLoader must not unload all libraries in its destructor without checking usage counts.

@davetcoleman
Copy link
Member

Wow, I'm impressed you dug that deep and found this. I believe I've occasionally seen this issue, too. I haven't tested it but it seems like a good merge, +1

@sachinchitta
Copy link
Contributor

I tried this a bunch (with the jade source branches though) running demo.launch and killing it. Rviz does not crash for me always - in fact very rarely. I do think this is a good fix but is there a demo.launch you are using that is always making this happen?

sachinchitta added a commit that referenced this pull request Oct 1, 2015
@sachinchitta sachinchitta merged commit 0c3696f into moveit:indigo-devel Oct 1, 2015
@sachinchitta
Copy link
Contributor

Ok - seemed to be happening in indigo but not in jade.

@rhaschke rhaschke deleted the fix-shutdown branch November 19, 2015 20:38
otamachan pushed a commit to otamachan/moveit_ros that referenced this pull request Oct 22, 2017
fixed segfault on shutdown
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants