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

Make loaned messages const on the subscription side #992

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from

Conversation

nnmm
Copy link
Contributor

@nnmm nnmm commented Jul 9, 2022

It seems to me that it is an error for the receiver of a loaned message to modify it – other subscriptions could be reading the same message at the same time. Therefore, this PR makes the API stricter by handing out only const pointers.

I have also made corresponding changes in rclcpp, which I'll open a PR for as well and link here.

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

I think this makes sense.

CC: @MiguelCompany @ivanpauno @wjwwood

@nnmm
Copy link
Contributor Author

nnmm commented Jul 12, 2022

Can somebody help me understand why the Rpr__rcl__ubuntu_jammy_amd64 check is red? I'm not familiar with Jenkins, and in the console log it says "0 tests failed".

@clalancette
Copy link
Contributor

Can somebody help me understand why the Rpr__rcl__ubuntu_jammy_amd64 check is red? I'm not familiar with Jenkins, and in the console log it says "0 tests failed".

It's because there are compiler warnings: https://build.ros2.org/job/Rpr__rcl__ubuntu_jammy_amd64/52/gcc/new/

@nnmm
Copy link
Contributor Author

nnmm commented Jul 12, 2022

It's because there are compiler warnings: https://build.ros2.org/job/Rpr__rcl__ubuntu_jammy_amd64/52/gcc/new/

Thanks. I'll get on it.

@nnmm
Copy link
Contributor Author

nnmm commented Jul 12, 2022

Should I also do this change in the rmw layer?

Copy link
Member

@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.

This makes sense to me!

@ivanpauno
Copy link
Member

Should I also do this change in the rmw layer?

Yes, and after that it would be nice to cleanup the casts that will become unnecessary here.

@ivanpauno
Copy link
Member

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

@ivanpauno
Copy link
Member

@nnmm there are some build failures related to the change.

@nnmm
Copy link
Contributor Author

nnmm commented Jul 12, 2022

@ivanpauno I'm not sure how this can be tested, but it needs the changes to rclcpp as well.

@ivanpauno
Copy link
Member

@ivanpauno I'm not sure how this can be tested, but it needs the changes to ros2/rclcpp#1971 as well.

ah sorry, my bad.
I didn't see the other PR.

@clalancette clalancette added the more-information-needed Further information is required label Jul 28, 2022
Copy link
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.

Sorry, I know this has been sitting a long time. I just took a look and suggested a way to make this better if you are still interested in making this happen.

@@ -630,7 +630,8 @@ rcl_take_loaned_message(
// Call rmw_take_with_info.
bool taken = false;
rmw_ret_t ret = rmw_take_loaned_message_with_info(
subscription->impl->rmw_handle, loaned_message, &taken, message_info_local, allocation);
subscription->impl->rmw_handle, (void **) loaned_message, &taken, message_info_local,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that rather than doing this cast here, we should first change rmw_take_loaned_message_with_info to take a const void ** loaned_message. At that point, everything will be const and no casts will be needed.

Same goes below for rmw_return_loaned_message_from_subscription.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-information-needed Further information is required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants