Skip to content

Return service from node_type_description_service_init - #1112

Merged
mjcarroll merged 5 commits into
rollingfrom
mjcarroll/fini_service
Oct 30, 2023
Merged

mjcarroll merged 5 commits into
rollingfrom
mjcarroll/fini_service

Conversation

@mjcarroll

@mjcarroll mjcarroll commented Oct 26, 2023 •

Copy link
Copy Markdown
Member

This changes the mechanism of rcl_node_type_description_service_init to populate a user-provided service.

This makes it the calling user's responsibility to call rcl_service_fini on the returned service, making it more in line with the rest of the rcl API.

This was discovered when working with the new rclcpp::WaitSet implementation.

The main issue is that the executor needs to share ownership with objects that it is wait-ing on for the entire duration of the wait, even if a node is removed from the executor at that time. That is, the executor doesn't have knowledge of the nodes so much as the waitable objects in the collection.

In this current implementation, the type_description was being fini-ed during the NodeTypeDescriptions destructor here: https://github.com/ros2/rclcpp/blob/fcbe64cff4bea3109531254ceb2955dc4b1bb320/rclcpp/src/rclcpp/node_interfaces/node_type_descriptions.cpp#L128-L139. This could cause a situation where a service is cleaned up while we are still waiting on it, and yields a segfault afterwards.

After discussion with @clalancette, it seems the better approach is to have the user init the service and then be responsible for managing the lifetime of that service through their client library (eg rclcpp::Service)

This makes the caller responsible for cleaning up the service.

Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll
mjcarroll force-pushed the mjcarroll/fini_service branch from 54a4d99 to 43dfecc Compare October 26, 2023 21:13
Comment thread rcl/src/rcl/node.c Resolved
Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll mjcarroll changed the title Make the fini of the type description service explicit Return service from node_type_description_service_init Oct 27, 2023
Comment thread rcl/include/rcl/node.h Resolved
Signed-off-by: Michael Carroll <[email protected]>
Comment thread rcl/include/rcl/node.h Resolved
Comment thread rcl/include/rcl/node.h Resolved
Michael Carroll added 2 commits October 28, 2023 02:33
Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll

Copy link
Copy Markdown
Member Author
  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya fujitatomoya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@mjcarroll mjcarroll self-assigned this Oct 30, 2023
@mjcarroll

Copy link
Copy Markdown
Member Author

One more run after some rebase/force-push:

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

@mjcarroll
mjcarroll merged commit 1b79535 into rolling Oct 30, 2023
@delete-merged-branch
delete-merged-branch Bot deleted the mjcarroll/fini_service branch October 30, 2023 19:24
clalancette added a commit that referenced this pull request Jun 25, 2024
In particular, make sure to match all service_description_init
with the appropriate finis.  While we are in here, also add in
a "service_not_exists" function that will quit much earlier,
speeding up the test.

This is essentially a backport of #1107
and parts of #1112, but adapted
for Iron.

Signed-off-by: Chris Lalancette <[email protected]>
clalancette added a commit that referenced this pull request Jun 25, 2024
In particular, make sure to match all service_description_init
with the appropriate finis.  While we are in here, also add in
a "service_not_exists" function that will quit much earlier,
speeding up the test.

This is essentially a backport of #1107
and parts of #1112, but adapted
for Iron.

Signed-off-by: Chris Lalancette <[email protected]>
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.

2 participants