Skip to content

Add a test for destroy_node while spinning#663

Merged
cottsay merged 5 commits intomasterfrom
cottsay/destroy_node_test
Apr 8, 2021
Merged

Add a test for destroy_node while spinning#663
cottsay merged 5 commits intomasterfrom
cottsay/destroy_node_test

Conversation

@cottsay
Copy link
Copy Markdown
Member

@cottsay cottsay commented Jan 15, 2021

I'm not sure if we ever intended to support calling Node.destroy_node() while another thread is spinning or not, but if you do so, the spinner will die with a segmentation fault.

This PR doesn't actually address the issue, it just adds a test to demonstrate the problem.

With rmw_cyclonedds_cpp:

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

With rmw_fastrtps_cpp:

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

Signed-off-by: Scott K Logan <logans@cottsay.net>
@cottsay cottsay added the bug Something isn't working label Jan 15, 2021
@cottsay
Copy link
Copy Markdown
Member Author

cottsay commented Jan 28, 2021

After some digging, it appears that the exception generated by rmw_fastrtps_cpp is expected.

The segfault when using rmw_cyclonedds_cpp results from the QoS event handlers being referenced during the call to rmw_wait after it is awoken. The call to destroy_node is deallocating those event handlers prior to rmw_wait waking up, hence the segfault.

Here is an example of this occuring on a macOS build: #667 (comment)

This doesn't appear to be a problem in rmw_fastrtps_cpp because it doesn't seem reference the data associated with the event handlers after rmw_wait wakes up in the same way that rmw_cyclonedds_cpp does.

The rmw_wait event handling was added to rmw_cyclonedds_cpp in ros2/rmw_cyclonedds#88, and the site of the fault is here:
https://github.com/ros2/rmw_cyclonedds/blob/d024823043504ea40af24bf22365a21cd203df55/rmw_cyclonedds_cpp/src/rmw_node.cpp#L3291

Signed-off-by: Scott K Logan <logans@cottsay.net>
The execption coming out of the spin thread when `rmw_fastrtps_cpp` is
used is actually caused by the call to `context.shutdown()`, and is
therefore expected behavior. We should make sure it happens that way.

Signed-off-by: Scott K Logan <logans@cottsay.net>
@clalancette
Copy link
Copy Markdown
Contributor

As we discussed, I've converted this to a draft PR and assigned it to one of the rclpy maintainers. This is probably something that we should try to fix for Galactic, so I'm also putting it on the Galactic board.

@clalancette
Copy link
Copy Markdown
Contributor

Now that we've merged #761, I think it is probably a good idea to rebase this one and see if it is fixed.

@clalancette
Copy link
Copy Markdown
Contributor

CI:

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

Signed-off-by: Scott K Logan <logans@cottsay.net>
@cottsay
Copy link
Copy Markdown
Member Author

cottsay commented Apr 8, 2021

Evidently I need to review my knowledge of the English alphabet.

After fixing the import order:

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

Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

Seems like a reasonable test to have to me! Should catch these kinds of issues in the future.

@cottsay cottsay marked this pull request as ready for review April 8, 2021 23:17
@cottsay cottsay merged commit ff25cf8 into master Apr 8, 2021
@delete-merged-branch delete-merged-branch bot deleted the cottsay/destroy_node_test branch April 8, 2021 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants