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

Retry fix for unsafe initialization in graph classes #612

Merged
merged 4 commits into from
Jul 31, 2024

Conversation

scpeters
Copy link
Member

🦟 Bug fix

Fixes #269.

Summary

The is a second attempt at fixing the potentially unsafe initialization issues in the graph::Edge and graph::Vertex classes after the first attempt in #606 was reverted in #609 due to test failures that it caused in gz-sim (documented in osrf/buildfarm-tools#67 (comment)). This pull request uses a static local variable instead of dynamic memory allocation and doesn't cause gz-sim test failures in my testing.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • 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 and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

caguero and others added 2 commits July 17, 2024 21:17
* Avoid constructor/destructor fiascos in graph class
* Deprecations and migration guide.

Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
@scpeters
Copy link
Member Author

using the ci_matching_branch/ technique with osrf/homebrew-simulation@e682b25 and gazebosim/gz-sim#2482, this branch and gazebosim/sdformat#1460 are test in gz-sim CI:

template<typename E, typename EdgeType>
EdgeType &NullEdge()
{
static EdgeType e(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still problematic depending the given types E, and EdgeType because the destructor eventually runs when the program exits. According to the Google style guide, it's best to allocate memory from the heap and never delete it, which will avoid calling the destructor. gz::utils::NeverDestroyed does exactly that, so I recommend we switch to that.

Copy link
Member Author

Choose a reason for hiding this comment

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

trying NeverDestroyed in 3fa9854

Copy link
Member Author

Choose a reason for hiding this comment

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

@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
Signed-off-by: Steve Peters <[email protected]>
@scpeters scpeters requested a review from azeey July 31, 2024 04:50
@scpeters scpeters merged commit f8c53b0 into main Jul 31, 2024
9 checks passed
@scpeters scpeters deleted the scpeters/retry_graph_init branch July 31, 2024 20:02
@iche033 iche033 mentioned this pull request Aug 21, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🏛️ ionic Gazebo Ionic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants