Repository navigation
Destroy plugin instances before their class loader (kilted) - #352
Open
MatthijsBurgh wants to merge 1 commit into
Open
MatthijsBurgh wants to merge 1 commit into
MatthijsBurgh wants to merge 1 commit into
Conversation
~RosPluginlibPluginProvider() deleted the class loader in the destructor body, while the plugin instances in instances_ and libraries_to_unload_ are members and therefore were only destroyed afterwards. On closing rqt with a C++ plugin loaded, class_loader then reported: SEVERE WARNING!!! Attempting to unload library while objects created by this loader exist in the heap! Release the instances first. rolling already has this order since ros-visualization#339. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthijs van der Burgh <matthijs.van.der.burgh@vbti.nl>
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closing rqt with a C++ plugin loaded prints this on every shutdown:
Reproduce:
rqt --standalone rqt_image_view, then close it (or Ctrl+C).Cause
On application close, plugins are shut down but not unloaded, so
RosPluginlibPluginProviderstill holds theirshared_ptrs ininstances_. Its destructor deletesclass_loader_in the destructor body, whileinstances_andlibraries_to_unload_are members and are only destroyed after the body. The class loader is therefore asked to unload the plugin library while the plugin object is still alive.A gdb backtrace at the warning shows the path (library being unloaded:
librqt_image_view.so):Fix
Clear
libraries_to_unload_andinstances_in the destructor before deleting the class loader.rollingdoes not need this: since #339class_loader_is aunique_ptrdeclared before the two containers, so the instances are already destroyed first. I checked a current rolling install (qt_gui_cpp 3.0.4) and it does not print the warning. That is why this targetskilteddirectly instead of going through rolling. The same change is proposed for the other affected branches (jazzy, kilted, lyrical).Testing
On the
ros:kilted-ros-basecontainer (qt_gui_cpp 2.9.3, class_loader 2.8.1), runningQT_QPA_PLATFORM=offscreen rqt --standalone rqt_image_viewand stopping it with SIGINT:qt_gui_cppandrqt_gui_cpprebuilt with this change: warning printed in 0 of 3 runsrqt_gui_cpphas to be rebuilt as well, since it instantiates the template from this header.🤖 Generated with Claude Code