-
Notifications
You must be signed in to change notification settings - Fork 263
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
EntityByComponents causes a crash on exit #1158
Comments
With the new
|
I just noticed another crash that I believe is related to this when I run
|
I spent sometime looking into this and I've found one issue (I don't know if there are multiple) that causes the crash. I have MWE in https://github.com/azeey/sandbox/tree/master/use_ecm_in_shared_libraries, but to summarize, the views created in the gui plugins have their virtual destructors stored in the plugins' shared library. A segfault occurs if the |
Yes, I believe so. I don't know what the solution is other than keeping the plugins loaded. I think it's okay to run the destructors of the plugins, but not okay to completely unload them from memory, unless we come up with a different solution. |
Thanks for looking into this, @azeey. I wasn't aware of the effects of unloading shared libraries early, so I learned something new! I took a look at the MWE you shared, and read the following:
I'm having a hard time understanding why the virtual destructors are in the shared library instead of the main application, since the ECM (which holds a pointer to Would you mind explaining why the virtual destructor is placed in the shared library so that I can have a better understanding? |
It happens because |
Interesting, so even though the views are stored in the Okay, well if this is the issue for the crash, should we not completely unload GUI plugins from memory? Or would this have any potential drawbacks? |
Yeah, the object data stored inside
Since this will affect all plugins, not just GUI plugins, it would be great if we could come up with a solution that doesn't require us to leave plugins loaded in memory. One drawback of leaving them loaded is memory consumption. Another is how they might make it difficult to implement World Reset. For the short term, leaving them loaded might be our solution. If we can find a way to make |
As discussed in #1158, a segfault occurs during exit because Views created as a result of an ECM query by plugins have their destructors stored in the shared library of the plugin. For GUI plugins, the plugins are unloaded from memory before the ECM is destructed, so when it's time to destruct the Views, a segfault occurs because the pointer to the virtual destructor is invalid. This PR is fixes the problem by making View a regular class instead of a template. This ensures that the destructor of View is stored in the core library of ignition-gazebo. As a result, the ECM can be destructed after GUI plugins have been unloaded. Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
As discussed in gazebosim#1158, a segfault occurs during exit because Views created as a result of an ECM query by plugins have their destructors stored in the shared library of the plugin. For GUI plugins, the plugins are unloaded from memory before the ECM is destructed, so when it's time to destruct the Views, a segfault occurs because the pointer to the virtual destructor is invalid. This PR is fixes the problem by making View a regular class instead of a template. This ensures that the destructor of View is stored in the core library of ignition-gazebo. As a result, the ECM can be destructed after GUI plugins have been unloaded. Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com> Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
As discussed in gazebosim#1158, a segfault occurs during exit because Views created as a result of an ECM query by plugins have their destructors stored in the shared library of the plugin. For GUI plugins, the plugins are unloaded from memory before the ECM is destructed, so when it's time to destruct the Views, a segfault occurs because the pointer to the virtual destructor is invalid. This PR is fixes the problem by making View a regular class instead of a template. This ensures that the destructor of View is stored in the core library of ignition-gazebo. As a result, the ECM can be destructed after GUI plugins have been unloaded. Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com> Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
As discussed in #1158, a segfault occurs during exit because Views created as a result of an ECM query by plugins have their destructors stored in the shared library of the plugin. For GUI plugins, the plugins are unloaded from memory before the ECM is destructed, so when it's time to destruct the Views, a segfault occurs because the pointer to the virtual destructor is invalid. This PR is fixes the problem by making View a regular class instead of a template. This ensures that the destructor of View is stored in the core library of ignition-gazebo. As a result, the ECM can be destructed after GUI plugins have been unloaded. Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com> Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Environment
source build,
ign-gazebo6
branchDescription
When calling
EntityByComponents
with certain combination of components as filters inside a gui plugin, ign-gazebo will crash on exit.The
EntityByComponents
call creates a new View that's stored in the EntityComponentManager class (this->dataPtr->views
). The cause of the crash seems to be related to deletion of the views when the unique pointer goes out of scope.The following will cause a crash in the ECM / BaseView default destructor
You can replace
components::Name
above with with any other component and it'll still crash.Interestingly, the calls below do not cause a crash on exit:
Steps to reproduce
Entity Tree
'sUpdate
functionx
button on top right to exit, and confirm exit -> crashThe text was updated successfully, but these errors were encountered: