-
Notifications
You must be signed in to change notification settings - Fork 38
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
Bump polling and socket2 version to latest #172
Bump polling and socket2 version to latest #172
Conversation
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.
Thanks for the PR. Unfortunately bringing in unsafe
in this case is a big no-no.
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.
Thanks for the PR. Unfortunately bringing in
unsafe
in this case is a big no-no.
It’s good to be cautious about introducing unsafe
blocks, but there's a compelling reason to reconsider in this instance.
The need for unsafe
arises from the Poller::poll
function in the polling crate being inherently "I/O unsafe", a characteristic that is now explicitly indicated in the function signature and documentation with the release of polling 3.x.
This change, although a significant shift, simply makes explicit what was previously an implicit requirement: the necessity for the RawFd
to be valid as long as it’s held by the Poller
.
You can check the PR for more details: smol-rs/polling#123
The I/O safety RFC is also explicitly documenting that such functions should be marked as unsafe
:
Functions accepting arbitrary raw I/O handle values (RawFd, RawHandle, or RawSocket) should be unsafe if they can lead to any I/O being performed on those handles through safe APIs.
If we shy away from these unsafe
blocks, we’ll limit ourselves to the polling 2.x version indefinitely, which might not be in our best interest. The transition to acknowledging I/O safety aligns with the broader Rust community's efforts towards safer code.
I also propose taking additional steps to increase the code quality: enable lints like unsafe_op_in_unsafe_fn
, which will be enabled by default in Rust's next edition, and the clippy::undocumented_unsafe_blocks
/clippy::multiple_unsafe_ops_per_block
combo to guarantee that all unsafe operations are thoroughly documented and reviewed.
src/lib.rs
Outdated
#![forbid(unsafe_code)] | ||
#![allow(clippy::single_component_path_imports)] |
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.
Following my comment above, I suggest enabling these lints:
#![warn(unsafe_op_in_unsafe_fn)]
#![warn(clippy::undocumented_unsafe_blocks)]
#![warn(clippy::multiple_unsafe_ops_per_block)]
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.
We cannot remove #![forbid(unsafe_code)]
just because one dependency lib changed its API to be unsafe
. Sorry.
I am all for upgrading to the latest version of any dependency. But this particular API change in the lib seems making things worse, not better: It changed into Back to reality, yes looks like we have a problem with this dependency. As you said, we cannot limit to polling 2.x forever. I will try to see if |
Could you please clarify what you mean by "non-checkable"? My understanding is that a file descriptor remains valid from the moment it is returned by the OS until While I'm not here to advocate strictly for or against I/O safety, I do think it’s unlikely to "die" anytime soon, and we’ll have to consider it. I'd encourage looking into the RFC for a deeper dive into this topic and the ongoing "trend".
I understand and respect your position, and of course it’s your call. I’m all for avoiding
The first alternative is not good, and the second one almost sounds like a joke, so considering them as no-go we only have the last two options. About If it’s possible to go for the last option, that’s great. I’ll be following this. |
I meant that And I submitted a draft PR in |
To move forward, while I'm waiting on my PR in |
Sounds good to me. @irvingoujAtDevolution Do you think you can you look into this? |
Will do, thanks for you all! |
fe566e8
to
4d719a3
Compare
changed code accrodingly, we may need to pay extra attention and discuss on when to remove socket from poller as suggested by polling's documentation