Uh oh!
There was an error while loading. Please reload this page.
use SecRandomCopyBytes on macOS in Miri - #60156
Conversation
rust-highfive
commented
Apr 21, 2019
r? @Kimundi (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
oli-obk
commented
Apr 22, 2019
We can revisit once we are able to open |
RalfJung
commented
Apr 25, 2019
Another case where we might want to use Cc @Amanieu |
Amanieu
commented
Apr 25, 2019
There is already a |
Ah... yes we'd probably have to add that here. |
RalfJung
commented
Apr 27, 2019
@rust-lang/libs what do you think, is it reasonable to use |
sfackler
commented
Apr 27, 2019
If we're going to go the |
RalfJung
commented
Apr 27, 2019
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 |
Centril
commented
Apr 28, 2019
r? @oli-obk |
alexcrichton
commented
Apr 29, 2019
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 |
RalfJung
commented
May 1, 2019
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 |
bors
commented
May 1, 2019
📌 Commit 16ad977 has been approved by |
bors
commented
May 2, 2019
use SecRandomCopyBytes on macOS in Miri This is a hack to fixrust-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
bors
commented
May 2, 2019
☀️ 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 fixrust-lang/miri#686: on macOS, rustc will open
/dev/urandomto initialize aHashMap. That's quite hard to emulate properly in Miri without a full-blown implementation of file descriptors. However, Miri needs an implementation ofSecRandomCopyBytesanyway 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