Skip to content
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

Backport #188: Fix crash when using BVH animations #199

Merged
merged 1 commit into from
Apr 28, 2021

Conversation

adlarkin
Copy link
Contributor

@adlarkin adlarkin commented Apr 12, 2021

Signed-off-by: Ashton Larkin ashton@openrobotics.org

🦟 Bug fix

Related to gazebosim/gz-sim#647

Summary

This is a backport of #188. Once this is merged, we should no longer see actors crash at launch (the ign-common3 branch applies to both Citadel and Dome).

To test this, run ign gazebo -r actor.sdf and make sure no crash occurs.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

@adlarkin adlarkin requested a review from chapulina April 12, 2021 17:05
@adlarkin adlarkin requested a review from mjcarroll as a code owner April 12, 2021 17:05
@github-actions github-actions bot added 🏰 citadel Ignition Citadel 📜 blueprint Ignition Blueprint 🔮 dome Ignition Dome labels Apr 12, 2021
@adlarkin adlarkin added bug Something isn't working and removed 📜 blueprint Ignition Blueprint labels Apr 12, 2021
@codecov
Copy link

codecov bot commented Apr 12, 2021

Codecov Report

Merging #199 (5186393) into ign-common3 (f1c8c4a) will decrease coverage by 0.19%.
The diff coverage is 45.83%.

❗ Current head 5186393 differs from pull request most recent head ee6fe52. Consider uploading reports for the commit ee6fe52 to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##           ign-common3     #199      +/-   ##
===============================================
- Coverage        75.20%   75.00%   -0.20%     
===============================================
  Files               73       72       -1     
  Lines            10307    10290      -17     
===============================================
- Hits              7751     7718      -33     
- Misses            2556     2572      +16     
Impacted Files Coverage Δ
graphics/src/SkeletonAnimation.cc 40.74% <33.33%> (-1.73%) ⬇️
graphics/src/Skeleton.cc 42.17% <50.00%> (-0.43%) ⬇️
graphics/src/Animation.cc 91.56% <66.66%> (-0.34%) ⬇️
graphics/src/Image.cc 65.00% <0.00%> (-2.09%) ⬇️
graphics/include/ignition/common/Image.hh

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f1c8c4a...ee6fe52. Read the comment docs.

@adlarkin
Copy link
Contributor Author

adlarkin commented Apr 12, 2021

I tried testing this by running ign gazebo -r actor.sdf. I'm not sure why, but this does not seem to fix the actor crashing on citadel or dome. For citadel, the simulation starts, but then crashes after a few seconds. For dome, it crashes on launch and sometimes shows this error (other times, it shows a long backtrace similar to the backtrace in gazebosim/gz-sim#647):

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid

I'm not sure why this is happening. I'll need to look into it some more, unless someone else knows what's going on here?

@mjcarroll
Copy link
Contributor

@osrf-jenkins retest this please

@chapulina
Copy link
Contributor

I spent some time debugging the crashes on Citadel but the more I dig, the uglier it gets. I have added some safety checks on the following 2 branches:

My favorite one is the std::map that ends up with a size larger than its max_size 🤷‍♀️


I suspect that the best course of action right now should be to revert #136, because as the documentation says, the Skeleton doesn't own its Animations, so it shouldn't be deleting them. I don't know what is supposed to be deleting them though, so I'm not sure what's the correct way to avoid a memory leak. Maybe there was never a proper way to delete it.

What's best, a memory leak, or a segfault? ⚖️

https://github.com/ignitionrobotics/ign-common/blob/b7ac4ed8329d50aee7d8c3e92cdf9b307aef7c0b/graphics/include/ignition/common/Skeleton.hh#L135-L138

@adlarkin adlarkin force-pushed the adlarkin/backport_bvh_animation_crash_fix branch from d88af6f to a3983b6 Compare April 28, 2021 19:34
@adlarkin adlarkin requested a review from iche033 April 28, 2021 19:41
@adlarkin
Copy link
Contributor Author

@chapulina I believe I may have fixed the issue 🤞 since ign-common3 still uses a raw impl pointer, we need to do a deep copy here, or else we are just copying the pointer, which eventually goes out of scope. ign-common4 uses the new utils impl ptr, so that's why this wasn't needed in #188. I have added an assignment operator in a3983b6, and that seems to fix the crash for me.

More information about this can be found in #136 (comment).

/// \brief Assignment operator
/// \param[in] _other The new SkeletonAnimation
/// \return A reference to this instance
public: SkeletonAnimation &operator=(const SkeletonAnimation &_other);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function should not be merged forward to ign-common4 right? Can you add a note as a reminder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: af8b84a

Let me know if there's a better way/format of adding a note like this. I don't think it should be a TODO since nothing really needs to be "done", and I also assume it shouldn't be a doxygen comment since this isn't relevant for user documentation (it's more of just an internal developer note).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me.

Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiice! It works for me with the assignment operator 😃

Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
@adlarkin adlarkin force-pushed the adlarkin/backport_bvh_animation_crash_fix branch from af8b84a to ee6fe52 Compare April 28, 2021 22:46
@adlarkin adlarkin merged commit ee6fe52 into ign-common3 Apr 28, 2021
@adlarkin adlarkin deleted the adlarkin/backport_bvh_animation_crash_fix branch April 28, 2021 23:18
@mjcarroll mjcarroll mentioned this pull request May 3, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🏰 citadel Ignition Citadel 🔮 dome Ignition Dome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants