-
Notifications
You must be signed in to change notification settings - Fork 371
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
Implement libstd HashMap seeding on OS X #686
Comments
Uh, yes, this will be awful. Alternatively we could "just" grant the interpreter FS access. But of course that would break cross-execution. |
In order to keep file descriptors deterministic, we can use "symbolic file descriptors" (generate a new |
What is the point, if we allow programs to open and read files they are not deterministic any more anyway? For a given seed, we'll always assign the same file descriptors. Small changes elsewhere in the program might affect that, but the same is true for the non-determinism that we return. |
This is actually going to be really simple once rust-lang/rust#59879 is merged, since |
Assuming there are no other open file descriptors the sequential allocation is guaranteed by POSIX:
|
Unfortunately it turns out that |
Dang. :/ There is no precedent for this, but in principle we could also patch libstd to use the |
I think for a bunch of these APIs we should not reproduce the platform APIs, but add some attributes to a high level function that all platforms go through and hook miri into that. |
Actually, for the |
See #709 and rust-lang/rust#60156 |
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
Status update: libstd is moving to using the |
The current plan for |
Current status: should be fixed by rust-lang/rust#62082, but it may be a while until that lands. |
HashMap doesn't work with miri on macOS yet because of rust-lang/miri#686
HashMap doesn't work with miri on macOS yet because of rust-lang/miri#686
HashMap doesn't work with miri on macOS yet because of rust-lang/miri#686
PR #683 implemented support for random number generation on Windows and (relatively recent) Linux. This was accomplished by implementing
RtlGenRandom
andgetrandom
for Windows and Linux respectively.For OS X (and other Unix systems without
getrandom
), implementing random number generation is significantly more complicated. We need to implement the following:open
/openat
with/dev/random
and/dev/urandom
read
andclose
on the 'file descriptor' created above.On Linux, file descriptors appear to be assigned sequentially. However, I don't believe that anything actually guarantees this - in other words, this could potentially be considered a source of non-determinism.
The text was updated successfully, but these errors were encountered: