Skip to content

-Zmiri-seed doesn't work on macOS #842

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

Closed
jrmuizel opened this issue Jul 16, 2019 · 1 comment
Closed

-Zmiri-seed doesn't work on macOS #842

jrmuizel opened this issue Jul 16, 2019 · 1 comment
Labels
A-mac Area: Affects only macOS targets A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@jrmuizel
Copy link

Running the following on macOS with cargo miri test -- -Zmiri-seed=23

        let mut h = std::collections::hash_map::HashMap::new();
        h.insert("Foo".to_string(), 4);

gives:

error[E0080]: Miri evaluation error: can't call foreign function: open
   --> /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/fs.rs:465:13
    |
465 |             open64(path.as_ptr(), flags, opts.mode as c_int)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri evaluation error: can't call foreign function: open
    |
    = note: inside call to closure at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/mod.rs:140:19
    = note: inside call to `std::sys::unix::cvt_r::<i32, [closure@DefId(1:8451 ~ std[797b]::sys[0]::unix[0]::fs[0]::{{impl}}[13]::open_c[0]::{{closure}}[0]) 0:&&std::ffi::CStr, 1:&i32, 2:&&std::sys::unix::fs::OpenOptions]>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/fs.rs:464:18
    = note: inside call to `std::sys::unix::fs::File::open_c` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/fs.rs:456:9
    = note: inside call to `std::sys::unix::fs::File::open` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/fs.rs:906:9
    = note: inside call to `std::fs::OpenOptions::_open` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/fs.rs:902:9
    = note: inside call to `std::fs::OpenOptions::open::<&std::path::Path>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/fs.rs:370:9
    = note: inside call to `std::fs::File::open::<&str>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/rand.rs:85:24
    = note: inside call to `std::sys::unix::rand::imp::fill_bytes` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/rand.rs:9:9
    = note: inside call to `std::sys::unix::rand::hashmap_random_keys` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/collections/hash/map.rs:2449:23
    = note: inside call to `std::collections::hash_map::RandomState::new::KEYS::__init` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/ops/function.rs:231:5
    = note: inside call to `<fn() -> std::cell::Cell<(u64, u64)> {std::collections::hash_map::RandomState::new::KEYS::__init} as std::ops::FnOnce<()>>::call_once - shim(fn() -> std::cell::Cell<(u64, u64)> {std::collections::hash_map::RandomState::new::KEYS::__init})` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/thread/local.rs:285:25
    = note: inside call to `std::thread::local::lazy::LazyKeyInner::<std::cell::Cell<(u64, u64)>>::initialize::<fn() -> std::cell::Cell<(u64, u64)> {std::collections::hash_map::RandomState::new::KEYS::__init}>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/thread/local.rs:426:22
    = note: inside call to `std::thread::__FastLocalKeyInner::<std::cell::Cell<(u64, u64)>>::try_initialize::<fn() -> std::cell::Cell<(u64, u64)> {std::collections::hash_map::RandomState::new::KEYS::__init}>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/thread/local.rs:411:25
    = note: inside call to `std::thread::__FastLocalKeyInner::<std::cell::Cell<(u64, u64)>>::get::<fn() -> std::cell::Cell<(u64, u64)> {std::collections::hash_map::RandomState::new::KEYS::__init}>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/thread/local.rs:176:17
    = note: inside call to `std::collections::hash_map::RandomState::new::KEYS::__getit` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/thread/local.rs:254:32
    = note: inside call to `std::thread::LocalKey::<std::cell::Cell<(u64, u64)>>::try_with::<[closure@DefId(1:1022 ~ std[797b]::collections[0]::hash[0]::map[0]::{{impl}}[66]::new[0]::{{closure}}[0])], std::collections::hash_map::RandomState>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/thread/local.rs:234:9
    = note: inside call to `std::thread::LocalKey::<std::cell::Cell<(u64, u64)>>::with::<[closure@DefId(1:1022 ~ std[797b]::collections[0]::hash[0]::map[0]::{{impl}}[66]::new[0]::{{closure}}[0])], std::collections::hash_map::RandomState>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/collections/hash/map.rs:2452:9
    = note: inside call to `std::collections::hash_map::RandomState::new` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/collections/hash/map.rs:2525:9
    = note: inside call to `<std::collections::hash_map::RandomState as std::default::Default>::default` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/collections/hash/map.rs:1021:30
    = note: inside call to `<std::collections::HashMap<std::string::String, i32> as std::default::Default>::default` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/collections/hash/map.rs:226:9
note: inside call to `std::collections::HashMap::<std::string::String, i32>::new` at src/lib.rs:5:21
   --> src/lib.rs:5:21
    |
5   |         let mut h = std::collections::hash_map::HashMap::new();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@RalfJung
Copy link
Member

RalfJung commented Jul 16, 2019

The default HashMap is unfortunately not supported on macOS currently. This should be fixed eventually when rust-lang/rust#62082 lands.

You can use a deterministic hasher with the libstd HashMap instead, that should work:

let map: HashMap<K, V, BuildHasherDefault<collections::hash_map::DefaultHasher>> = HashMap::default();

Closing as duplicate of #686.

@RalfJung RalfJung added A-mac Area: Affects only macOS targets A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement labels Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mac Area: Affects only macOS targets A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

No branches or pull requests

2 participants