-
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
Can't call foreign function: GetCurrentProcessId on windows #1727
Comments
Yeah, In non-isolated mode, we can probably just call |
I don't see how it would cause problems, but then I'm not exactly an expert when it comes to this. |
Isn't this already pretty much done since 2022 for the non-isolated case? "GetCurrentProcessId" if this.frame_in_std() to "GetCurrentProcessId" I don't have a pressing need for it, but it's slightly strange today that this has a if this.frame_in_std() but the unix one does not - see https://github.com/rust-lang/miri/blob/3e03054ef0056e728a081b03cde8546f91c822aa/src/shims/unix/foreign_items.rs . RE: fake PID, can't speak to that either. Probably best to steer away from allowing it in isolated mode. Maybe one could safely use zero: https://blog.dave.tf/post/linux-pid0/ Happy to put in a 1-line patch to close this out if it'd be useful. |
Hm, good point, I don't see why So yes please submit a PR. :) Please also move that match arm up into the "Environment related shims" section of the file then, to keep up the organization. |
…id_fixup-03, r=RalfJung Remove GetCurrentProcessId's frame_in_std check Most of the support required to close rust-lang#1727 was actually added a while back, in rust-lang#2215. However, for some reason, even though the Unix/Linux syscall equivalent has no `frame_in_std()` check, the Windows `GetCurrentProcessId` check did. While the vast majority of use cases use `std::process::id`, there's no particular reason to penalize any Windows code that is no_std or for whatever other reason choses to call the function directly (e.g. via the generated [windows-sys](https://docs.rs/windows-sys/latest/windows_sys/Win32/System/Threading/fn.GetCurrentProcessId.html) method). The emulation should still work fine. Given there's no reason not to, we might as well simplify the code a tiny bit and save that branch / frame check during runtime too. This PR removes the `frame_in_std` restriction for `GetCurrentProcessId`, and also moves it into the environment related shim section per discussion in rust-lang/miri#1727 (comment). Still passes existing tests/pass/getpid.rs test. Closes rust-lang#1727 unless we wish to give a dummy value when isolated, which we don't seem to want to do at this time.
I'm getting this when I call
cargo miri run
on my project:Let me know what other data I can provide.
Let me know what other data I can provide.
The text was updated successfully, but these errors were encountered: