Skip to content
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

ip_mreqn roundtrip test fails for mips64 and sparc64 #1558

Open
gnzlbg opened this issue Oct 17, 2019 · 2 comments
Open

ip_mreqn roundtrip test fails for mips64 and sparc64 #1558

gnzlbg opened this issue Oct 17, 2019 · 2 comments

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 17, 2019

See discussion in #1555 . This link contains experiments for Rust and C: https://rust.godbolt.org/z/ak3pec

This struct has 3 fields, where each field is 4 bytes wide. The first two fields are a struct { u32 }, while the last fields is an i32. The struct is 12 bytes wide - no padding.

The roundtrip test initializes the struct bytes in Rust to the following values: [0, 1, 2, 3, ..., 11]. It then passes the struct by value to a C function expecting it. This function then reads the bytes of the struct and verifies that they match the values set on the Rust side. This fails, reporting that the last 4 bytes (the ones of the i32) are read as [0, 0, 0, 0] instead if [8, 9, 10, 11].

What we know:

  • the struct is available from the C headers, otherwise the C example that uses it without declaring it would not compile
  • the struct name, size, alignment requirement, as well as the field offsets of the struct match those of the C definition, because those tests do pass

So AFAICT the only thing that might be causing the error is an incorrect "call ABI", where the content of the 3rd struct field is being passed in the wrong register, and when C reads it from the right one, the contents are zeroed.

@nikic
Copy link

nikic commented Oct 17, 2019

Based on your godbolt link, looks like rustc is passing { i64, i32 }, while C expects i64, i32. Not sure what the effect of that is though.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 18, 2019

Not sure either :/

bors added a commit that referenced this issue Jan 22, 2022
Define ip_mreqn on all Linux platforms

Closes #1558.
bors added a commit that referenced this issue Jan 24, 2022
Define ip_mreqn on all Linux platforms

Updates #1558.
bors added a commit that referenced this issue Jan 24, 2022
Define ip_mreqn on all Linux platforms

Updates #1558.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants