-
Notifications
You must be signed in to change notification settings - Fork 67
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
Conversation
* 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]>
Signed-off-by: Steve Peters <[email protected]>
using the |
include/gz/math/graph/Edge.hh
Outdated
template<typename E, typename EdgeType> | ||
EdgeType &NullEdge() | ||
{ | ||
static EdgeType e( |
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.
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.
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.
trying NeverDestroyed
in 3fa9854
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.
rerunning gz-sim CI https://build.osrfoundation.org/job/gz_sim-ci-pr_any-homebrew-amd64/693/
Signed-off-by: Steve Peters <[email protected]>
🦟 Bug fix
Fixes #269.
Summary
The is a second attempt at fixing the potentially unsafe initialization issues in the
graph::Edge
andgraph::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
codecheck
passed (See contributing)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.