Open
Description
If your program attempts to open and read from a file in /proc/self/fd/
, then cargo miri run
(with isolation disabled) hangs.
use std::os::fd::AsRawFd;
use std::fs::File;
use std::io::{Read, Seek, Write};
fn main() {
let mut file = tempfile::tempfile().unwrap();
file.write_all(b"hello").unwrap();
file.rewind().unwrap();
// opening and reading from /proc cause miri to become stuck
let mut new_file = File::open(format!("/proc/self/fd/{}", file.as_raw_fd())).unwrap();
//let mut new_file = file;
let mut buf = Vec::new();
new_file.read_to_end(&mut buf).unwrap();
println!("{buf:?}");
}
$ cargo --version
cargo 1.85.0-nightly (769f622e1 2024-12-14)
$ MIRIFLAGS=-Zmiri-disable-isolation cargo miri run
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Running `/home/steve/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner target/miri/x86_64-unknown-linux-gnu/debug/miri-test`
This is also reproducible at:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d05155bb1f3c7aff5e705b0e2904d21c
I'm guessing that miri virtualizes filesystem operations in some way, and maybe files in /proc
just aren't supported?