-
Notifications
You must be signed in to change notification settings - Fork 348
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
Windows file system shims are missing #3482
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Thanks again for your fast response. What I currently do, is that I run the complete unittest suite on windows and skip the tests which (i) access the filesystem or (ii) a foreign function. This works actually quite well and thanks to miri I already found a few places of undefined behavior. That's marvelous! With this ticket I could also run the tests which access the filesystem and would only need to skip the tests with the foreign function. Regarding external C dependencies: Is this the topic of #2365? |
Okay, so the problem is getting the build scripts to shut up and do nothing so that you can use
Yes.
Awesome. :) If these bugs have a public track record / issue / PR somewhere, we always appreciate PRs that add more bugs to the "bugs found with Miri" list in the readme. :D |
Thanks again for your fast response and help. This is really a great project!
Unfortunately the issues are in the closed source components, thus I cannot share. However, if interesting for you here the error messages of the discovered errors:
|
I'm also interested in this and might be willing to take a crack at adding support. @RalfJung, maybe you could clarify what the main challenge to doing this? I'm not asking you guys to do it, just seeking to understand what I'd be getting myself into. Is it cross-emulation? E.g. emulating the behavior of Windows FS apis on Linux? Naively, it seems like |
Both Windows API knowledge and free time is in very short supply around here. |
It's mostly about knowing the windows APIs involved so that all the behavior of these functions, and the UB checks, can be implemented, ideally using only the Rust std APIs: for Unix we are implementing open, read, write, close, readdir etc on top of std::fs::File and friends. The same would be the goal for the corresponding Windows functions.
We don't aim to implement the entire gigantic API surface of Windows, just the parts that std calls. I hope that would not be *that* many functions? For functions that expose a large API via opcodes/flags, but std uses only a fraction of that, we also usually implement only that fraction, at least in the first iteration.
So as Ben said, Windows API knowledge and time are the main things missing. We can help with the required Miri knowledge :)
|
I wouldn't personally call myself a Windows API expert, but I definitely know folks who have expertise. But no promises as is often the case RE time :(. Even the fraction that std uses is pretty comprehensive. Ex: WriteFile vs NtWriteFile, and ReadFileEx vs NtReadFile - looks like pipes for std::process use one and std::fs used the other. And so on. It should be possible to do in terms of Rust std:: apis, I think anyway. Here's some Microsoft docs that are relevant and publicly available (in case anyone finds them interesting / in case I don't have a chance to attack this). |
The std::process APIs are not very interesting for Miri yet. Not only is spawning other processes unsupported on Linux because we would need many more shims, it's not even clear how that would be implemented. Would we spawn a new interpreter? IPC would get weird. |
Ah, yeah, good point. Nor is std::process something I personally need. Yeah, if it's mostly sync I/O without the fancy stuff (APC or IOCP or similar), maybe it's not too bad. Still a significant number, but tractable, with this presumably being most of the list. |
We do have some odd bits in the standard library. For example, we need to guard synchronous read/write functions against asynchronous file handles, which are safe to create. And maybe don't even look at But if you do have any questions about the standard library then feel free to ping me. |
Maybe don't ever look at it. On Unix, std uses the fallback impl of it when running in miri. |
I hope we'll get rust-lang/rust#120426 at some point and then we can implement more POSIX APIs in Miri on top of that and start using the real impl in Miri... but anyway, that's off-topic here. :) |
I'm working on this in my free time the past couple of days, and have... 6/13 functions of the shims/fs.rs test working so far. Will open a PR once everything is at least basically implemented. |
Ideally make the first PR as small as possible, that will make everything easier. :) So if there's a subset of functions that can make a very simple test case work, please go for just that subset in the first PR. |
Ah, if that's preferred, I can try to split off just the bare-minimum open/meta/read/write/close support when I have some time. That lets us do the most simple and common of file operations. |
Yes that sounds like the better plan -- thanks. :) |
Glad to hear that someone is working on this - apologies that I didn't get to it. If it'd be helpful to have folks with Windows Filesystem API knowledge help review the PRs to add Windows shims, happy to help find subject matters experts from Microsoft to help. CC'ing Arlie Davis (@sivadeilra) as well - as he's probably forgotten more about Windows APIs than I've ever known 😄. |
Currently, those three are the only ones up. I have more implemented locally, but I'm focusing on getting minimal support upstreamed before I continue with more in-depth support. I can try to remember to tag you on future PRs I open for this project if you'd like. |
Miri supports accessing the file system (opening, reading, writing files; listing directories) on Unix systems, but not on Windows. This is probably the biggest remaining gap in our Windows support.
If you run into this, try
cargo miri test --target x86_64-unknown-linux-gnu
. This works even on a Windows host (without installing anything extra) and interprets programs on a well-supported Linux target -- file system access should generally work then. If it doesn't please file an issue (do not comment on this issue, instead file a new one).Nobody on the Miri team is very knowledgeable in Windows APIs, and a reasonable work-around exists for Windows users, so this is unlikely to be on our agenda any time soon. Contributions are always welcome though. :)
The text was updated successfully, but these errors were encountered: