-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
use SecRandomCopyBytes on macOS in Miri #60156
Conversation
r? @Kimundi (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
We can revisit once we are able to open |
Another case where we might want to use
Cc @Amanieu |
There is already a |
Ah... yes we'd probably have to add that here. |
@rust-lang/libs what do you think, is it reasonable to use |
If we're going to go the |
Probably. However, then we'd have to figure out what it is that Miri would have to hook instead. Also, Miri would still need to emulate all of these for the |
r? @oli-obk |
I'd agree with @sfackler that this seems like something where over time we'll want dedicated support for this rather than a few #[cfg] here and there. For now though I don't think we've crossed that threshold so if @RalfJung prefers to take this route it seems reasonable. We should remain watchful though in the sense that if we find we're taking a lot of these PRs we may want to add a first-class miri target sorta |
Alternatively, maybe Miri can reuse some of the work for WASI here. The constraints of both seem to be similar. For now though, I think this is good enough. @bors r=oli-obk,alexcrichton |
📌 Commit 16ad977 has been approved by |
use SecRandomCopyBytes on macOS in Miri This is a hack to fix rust-lang/miri#686: on macOS, rustc will open `/dev/urandom` to initialize a `HashMap`. That's quite hard to emulate properly in Miri without a full-blown implementation of file descriptors. However, Miri needs an implementation of `SecRandomCopyBytes` anyway to support [getrandom](https://crates.io/crates/getrandom), so using it here should work just as well. This will only have an effect when libstd is compiled specifically for Miri, but that will generally be the case when people use `cargo miri`. This is clearly a hack, so I am opening this to start a discussion about whether we are okay with such a hack or not. Cc @oli-obk
☀️ Test successful - checks-travis, status-appveyor |
fix Miri This reverts rust-lang#60156, which turned out to be a dead end (see rust-lang#60469). r? @oli-obk
This is a hack to fix rust-lang/miri#686: on macOS, rustc will open
/dev/urandom
to initialize aHashMap
. That's quite hard to emulate properly in Miri without a full-blown implementation of file descriptors. However, Miri needs an implementation ofSecRandomCopyBytes
anyway to support getrandom, so using it here should work just as well.This will only have an effect when libstd is compiled specifically for Miri, but that will generally be the case when people use
cargo miri
.This is clearly a hack, so I am opening this to start a discussion about whether we are okay with such a hack or not.
Cc @oli-obk