-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gazebo does not destroy plugins in the reverse order w.r.t. to which they have been created #3192
Comments
Downstream issue: robotology/gazebo-yarp-plugins#582 . |
In https://github.com/traversaro/gazebo/tree/fixReverseOrder I added a tests (for now without assertions) that showcase this problem. It loads a model like: <model name="parent_model">
<plugin name="plugin1" filename="libReverseDestructionOrderTestPlugin.so" />
<model name="nested_model">
<link name="nested_link" />
<plugin name="plugin2" filename="libReverseDestructionOrderTestPlugin.so" />
<plugin name="plugin3" filename="libReverseDestructionOrderTestPlugin.so" />
</model>
</model> And the load/destruction patterns are:
Note that the order is not the same in which the plugin are loaded, nor the reverse one. I will be happy to provide a PR for fixing this, but I would prefer to have before the discussion on whater such a PR could be accepted or if such change is exclued a priori as it is too risky. fyi @scpeters |
The issue is much more complex, as there is a similar issue regarding the order in which links and joints (and consequently their sensor and the related plugins) are created and destructed w.r.t. to their models. For my specific issue (robotology/gazebo-yarp-plugins#582) I found another solution to manage explicitly the order in which I call the cleanup sequence of the plugins, so I will close this issue. |
A common pattern in computer science in general is to destroy resources in the opposite value in which they have been created, i.e. if A and B are constructed/allocated/started in this order, destroy/deallocate/free/stop first B and then A, so that if there is any dependency of B on A, you do not risk that B crashes as A has been destroyed before.
According to a few experiments, this is not the case for many plugins in Gazebo (while for other it is, depending on where they are). In particular, for plugins belonging to the same model Gazebo stores the plugin shared pointers in
Model::plugins
data structure, see:However during model destruction, there is no attempt to destroy the plugin in reverse order w.r.t. to loading order:
I can provide a patch for this behaviour, however note that touching the destruction order could have unintended consequences, as it seems a behaviour that is quite prone to Hyrum's Law .
The text was updated successfully, but these errors were encountered: