-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
sanitize_standard_fds: Miri supports poll now #159961
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
Merged
rust-bors
merged 2 commits into
rust-lang:main
from
RalfJung:miri-sanitize_standard_fds
Jul 27, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/tools/miri/tests/pass-dep/libc/libc-poll-std-handles.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| //! Ensure we can poll the std handles, both the normal ones and the "null" ones. | ||
| //@ignore-target: windows # no libc | ||
| //@revisions: normal null | ||
| //@[null]compile-flags: -Zmiri-mute-stdout-stderr | ||
| //@run-native | ||
|
|
||
| #[path = "../../utils/libc.rs"] | ||
| mod libc_utils; | ||
| use libc_utils::*; | ||
|
|
||
| fn main() { | ||
| let pfds: &mut [_] = &mut [ | ||
| libc::pollfd { fd: 0, events: libc::POLLOUT | libc::POLLIN, revents: 0 }, | ||
| libc::pollfd { fd: 1, events: libc::POLLOUT | libc::POLLIN, revents: 0 }, | ||
| libc::pollfd { fd: 2, events: libc::POLLOUT | libc::POLLIN, revents: 0 }, | ||
| ]; | ||
| let num = errno_result(unsafe { libc::poll(pfds.as_mut_ptr(), 3, 0) }).unwrap(); | ||
| assert_eq!(num, 3); | ||
|
|
||
| assert_eq!(pfds[0].revents, libc::POLLIN | libc::POLLOUT); | ||
| assert_eq!(pfds[1].revents, libc::POLLOUT); | ||
| assert_eq!(pfds[2].revents, libc::POLLOUT); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Frustrated that these both are very similar errors that exist and mean slightly different things, but want to verify this is actually correct here. Based upon the Linux manual:
It feels like EBADFD is correct, but from what it seems, MacOS only has EBADF? And just want to verify this is correct since I'm not 100% sure.
View changes since the review
Uh oh!
There was an error while loading. Please reload this page.
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.
I only just realized that those two errors both exist and are different. I am fairly sure that we saw EBADF on macOS, not EBADFD, as EBADF is usually returned when calling
readon a closed FD so that would make sense. Also as you say macOS doesn't even seem to have EBADFD. I don't have macOS machine so verifying this isn't entirely trivial and doesn't seem worth it.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.
That's fair, then. My verification after poking around was the macos-errno crate which does indeed list EBADF and not EBADFD, so, I'll say that's good enough.