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

Fix node clean up #69

Merged
merged 1 commit into from
Jan 17, 2023
Merged

Fix node clean up #69

merged 1 commit into from
Jan 17, 2023

Conversation

nahueespinosa
Copy link
Member

This patch fixes the clean up order of node resources. Without it, the node would hang when shutting down due to circular dependencies with shared pointers.

Fixes #67.

@nahueespinosa nahueespinosa added bug Something isn't working cpp Related to C++ code labels Jan 16, 2023
@nahueespinosa nahueespinosa self-assigned this Jan 16, 2023
@nahueespinosa nahueespinosa changed the title Fix node clean up order Fix node clean up Jan 17, 2023
ivanpauno
ivanpauno previously approved these changes Jan 17, 2023
Copy link
Collaborator

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM!

@nahueespinosa
Copy link
Member Author

For future reference, in case someone wants to take a closer look into this. Here are some observations:

  • tf2_ros::MessageFilter<sensor_msgs::msg::LaserScan> holds a shared_ptr constructed from get_node_logging_interface().
  • Depending on whether we reset the laser_scan_filter_ on deactivate, we get different usage counts for the logging interface shared pointer at the time the node destructor finished executing:
    • 6 if laser_scan_filter_ was cleaned up properly
    • 7 otherwise
  • Having this extra instance after returning from the node destructor causes the node base class destructor to hang.

This patch fixes the clean up order of the node resources. Without it the node would hang when shutting down due to circular dependencies with shared pointers.

Signed-off-by: Nahuel Espinosa <nespinosa@ekumenlabs.com>
@nahueespinosa nahueespinosa merged commit 220952a into main Jan 17, 2023
@nahueespinosa nahueespinosa deleted the nahuel/fix_node_shutdown branch January 17, 2023 13:08
@nahueespinosa nahueespinosa added the ros Related to ROS label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cpp Related to C++ code ros Related to ROS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

amcl_node doesn't terminate after SIGINT
3 participants