Skip to content

Conversation

@Thomasdezeeuw
Copy link

@Thomasdezeeuw Thomasdezeeuw commented Dec 22, 2025

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.

@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2025

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Dec 22, 2025
@RalfJung
Copy link
Member

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.

@Thomasdezeeuw
Copy link
Author

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.
@Thomasdezeeuw
Copy link
Author

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 src/shims/unix/env.rs I would expect the code to be unix only, but it seems to be included on Windows as well, which then complains about missing the libc crate. @RalfJung any recommendations on what the best approach would be?

@saethlin
Copy link
Member

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. src/shims/unix is shims used when the --target is unix-like, not when the OS running the interpreter is. I'm using a lot of words because this took me time to get used to and what you tried to do here is a very common mistake when first implementing a shim.

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 cfg to pick a reasonable implementation on a non-unix system.

return this.set_last_error_and_return_i32(LibcError("EFAULT"));
}

let mut uname_buf = unsafe { std::mem::zeroed() };
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Waiting for a review to complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants