-
Notifications
You must be signed in to change notification settings - Fork 127
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
Wrap slice::from_raw_parts to be compatible with rcl #419
Conversation
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Awesome, thank you @mxgrey |
You said you saw this when running rclrs test, but how was this not failing in CI? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good to me! Good catch!
If I understand correctly, the panic was only put in starting around Rust version 1.78. I think the version of Rust on my own computer is 1.80, but we might only be using 1.74 in the CI. Maybe if we bumped the version in CI we'd see the failure. I can try to create a bogus PR to test that hypothesis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mxgrey good catch!
Makes sense. For the Rust projects that I manage, I use the latest stable version in CI and have the CI run for the main branch once a week, even if there have been no changes. That has allowed me to catch things that have broken due to upstream compiler changes right away. But targeting a specific version can reduce churn, so it's just a trade-off in priorities. |
Thats a great idea, we should do that here as well, with the latest stable Rust toolchain to catch any issues with the compiler |
Similar to #416, there are numerous places within rclrs that are at risk of runtime panics because
std::slice::from_raw_parts
may panic when it receives null pointer values. In particular I got this panic while runningcargo test
on rclrs:This PR adds a new internal function
rcl_from_raw_parts
which wrapsstd::slice::from_raw_parts
so that it's compatible with rcl's practice of returning null pointers to represent empty arrays. Then we replace every call tostd::slice::from_raw_parts
withrcl_from_raw_parts
.