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

Change the not_composable example to destroy subscription first. #210

Merged
merged 2 commits into from
Jun 25, 2018

Conversation

clalancette
Copy link
Contributor

We are seeing the following message when hitting Ctrl-C
in the subscriber not_composable node:

[ERROR] [rclcpp]: Error in destruction of rcl subscription handle: the Node Handle was destructed too early. You will leak memory

The problem is that setting g_node to nullptr causes the
node destructor to be run before the subscriber is destructed.
Due to another bug, we can't just remove that assignment, so
instead we make it all locally scoped in main for now, which
works around the problem.

Signed-off-by: Chris Lalancette clalancette@openrobotics.org

This worksaround #209

We are seeing the following message when hitting Ctrl-C
in the subscriber not_composable node:

[ERROR] [rclcpp]: Error in destruction of rcl subscription handle: the Node Handle was destructed too early. You will leak memory

The problem is that setting g_node to nullptr causes the
node destructor to be run before the subscriber is destructed.
Due to another bug, we can't just remove that assignment, so
instead we make it all locally scoped in main for now, which
works around the problem.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
@clalancette clalancette added the in progress Actively being worked on (Kanban column) label Jun 22, 2018
@clalancette
Copy link
Contributor Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@clalancette clalancette added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 22, 2018
/* We do not recommend this style anymore, because composition of multiple
* nodes in the same executable is not possible. Please see one of the subclass
* examples for the "new" recommended styles. This example is only included
* for completeness because it is similar to "classic" standalone ROS nodes. */

void topic_callback(const std_msgs::msg::String::SharedPtr msg)
{
RCLCPP_INFO(g_node->get_logger(), "I heard: '%s'", msg->data.c_str())
RCLCPP_INFO(rclcpp::get_logger("minimal_subscriber"), "I heard: '%s'", msg->data.c_str())
Copy link
Member

Choose a reason for hiding this comment

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

This is not the same thing. This function actually does need the node instance to maintain the existing behavior (and the existing behavior is the desired behavior in my opinion).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All right, in that case, I've changed it to manually destroy the subscription first, which achieves the same effect. I've also updated the comment. Please take another look when you get a chance.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
@clalancette
Copy link
Contributor Author

CI for the new code:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@clalancette clalancette changed the title Change the not_composable example to not use a global node. Change the not_composable example to destroy subscription first. Jun 25, 2018
@clalancette clalancette merged commit 0f430bd into master Jun 25, 2018
@clalancette clalancette deleted the non-global-node branch June 25, 2018 17:45
@clalancette clalancette removed the in review Waiting for review (Kanban column) label Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants