rust-lang / miri

An interpreter for Rust's mid-level intermediate representation
Apache License 2.0
4.33k stars 329 forks source link

Windows console API shims are missing #2652

Open thomcc opened 1 year ago

thomcc commented 1 year ago

Miri punts on GetConsoleMode currently, which means that under miri, the stdlib's stdio implementation is rather different than reality. This means several things that don't work in reality will work under miri (such as writing invalid UTF-8 to stdout), and also that the windows stdio code continues to be untested (not as worrisome as some of the sys::windows code, although it's probably the trickiest code with regards to MaybeUninit. But generally, it would be nice for us to align reality with what miri tests.

I took a look and I'm not sure how to do this really. It seems like much of windows IO is smoke and mirrors. So this almost certainly requires implementing a few other calls as well, such as WriteConsoleW and the like, although I think you can just implement console coloring as a no-op for now.

RalfJung commented 1 year ago

Yeah, on Windows I generally did the bare minimum needed to get the tests to pass. Many functions are barely functional stubs and certainly they are not modeling UB accurately. I'm happy to review PRs that improve Miri in this area but won't work on that myself.