-
Notifications
You must be signed in to change notification settings - Fork 423
Add a shim for uname systemcall #4784
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
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
|
Thanks for the PR! Please extend the PR description, explaining the motivation for why adding this syscall is helpful and why it makes sense to return some hard-coded "dummy" data. |
|
This is my first contribution to Miri, so I probably did something not quite right. If so, please let me know. I tried to follow the conventions I found in the code as the contribution guide didn't provide a lot of guidance around adding support for new system calls. |
Seems like most the BSD family (FreeBSD, OpenBSD, NetBSD, macOS) doesn't have this fields, only Linux.
x86_64 uses i8, aarch64 seems to use u8.
|
Updated the pr description. I think I also solved most issues found by the CI, but the Windows one I'm not sure of. In |
|
In general, it is wrong to implement shims in Miri by just calling the shimmed function in the shim, which is what you are trying to do. Miri is a cross-interpreter, so it needs to be able to run Linux code on Windows. Ideally, you implement a shim by calling a portable function in the standard library. If that is not available, you might be able to use |
| return this.set_last_error_and_return_i32(LibcError("EFAULT")); | ||
| } | ||
|
|
||
| let mut uname_buf = unsafe { std::mem::zeroed() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, we try to avoid unsafe in the interpreter except where it is absolutely necessary.
This system call is used to get information about the OS that is run. A10 for example uses this to determine what Linux version is being run and uses it to skip tests that are not supported by older Linux versions, see https://github.com/Thomasdezeeuw/a10/blob/87d04713a3ff5f9d60e1473a72939a1e1bcdaf13/tests/util/mod.rs#L44-L62.
When Miri runs in isolation mode this returns some dummy data based on a recent Linux version. Since the data should only be informative I think it makes sense to return something and allow the program to continue rather than stopping it.