-
Notifications
You must be signed in to change notification settings - Fork 276
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
Fix crash on GUI entity removal with levels #913
Fix crash on GUI entity removal with levels #913
Conversation
Signed-off-by: Ashton Larkin <[email protected]>
I think the diff_drive plugin is creating various vel cmd components on every PreUpdate for entities that no longer exist hence causing the crash. We should probably fix the diff drive plugin too. Maybe print an error in
yeah that sounds good to me. |
Signed-off-by: Ashton Larkin <[email protected]>
Signed-off-by: Ashton Larkin <[email protected]>
Done in fd46a05 I have also updated the diff_drive plugin to skip removed entities in #927. Once that change gets forward-ported to main, we should be able to merge this PR (I have started the forward-port process in #933). |
@iche033, the diff drive plugin should now be fixed in all released versions (#927 has been forward-ported from Citadel to Fortress). Would you mind testing the bug you found in #856 (review) one last time before I merge it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI caught a compilation error and I can reproduce it locally. Looks like it could be introduced due to recent changes in the target branch
EntityComponentManager_TEST.cc:233:3: required from here
/home/osrf/code/ign_f_ws2/src/ign-gazebo/test/gtest/include/gtest/gtest.h:1527:11: error: no match for ‘operator==’ (operand types are ‘const std::pair<long unsigned int, long unsigned int>’ and ‘ignition::gazebo::v6::components::Component<int, ignition::gazebo::v6::components::IntComponentTag>* const’)
if (lhs == rhs) {
Signed-off-by: Ashton Larkin <[email protected]>
Oops, it looks like that came from 158a1af 😅 it should be fixed in 713c848. I just tested the levels world, and removing entities seemed to work fine for me. Just as a note, I typically just build gazebo from source and then use the binary dependencies for PR testing, but I found that I also had to build |
works for me. I can't reproduce the Server test failures on ubuntu and does not look like it's introduced by changes in this PR. We can get this in first and check CI results again in #856 |
Signed-off-by: Ashton Larkin [email protected]
🦟 Bug fix
Fixes #856 (review)
Summary
After debugging the segfault pointed out in the link above, it seems like the levels system still tries to add components to entities even after they're removed (I'm not 100% certain if levels is to blame for this, but when I removed an entity in the
shapes.sdf
world, I did not see this behavior). This caused a segfault in #856 because components are not created if an entity doesn't exist, but the non existing entity (and component) were still marked as modified. This "mismatch" in data is problematic whenEntityComponentManagerPrivate::CalculateStateThreadLoad
is called inEntityComponentmanager::State
, so, this PR adds a check when callingEntityComponentManager::CreateComponentImplementation
to make sure that the entity exists.While the bug fix here ended up being a simple one, I found something interesting when comparing #856 to the
main
branch. In themain
branch, components are always created, regardless of whether an entity exists or not (I was also able to confirm this by testing the levels world that caused a segfault in #856 - as you can see, there's no checking for if the entity exists): https://github.com/ignitionrobotics/ign-gazebo/blob/c07b49c51caae6da1566c383d2b6ff91f4cb8097/src/EntityComponentManager.cc#L530-L566So, on the
main
branch, we don't see this segfault since both 1) the component is created, and 2) the (non existent) entity and the component are marked as modified. This actually seems like incorrect behavior to me, and I believe that we should fixmain
(and other released versions as well) to prevent creating components for entities that do not exist. @iche033, what do you think?Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge