rust3ds / ctru-rs

Rust wrapper for libctru
https://rust3ds.github.io/ctru-rs/
Other
122 stars 18 forks source link

rust-lang/libc seems to have incorrect definition for `sockaddr_in` #174

Open adryzz opened 7 months ago

adryzz commented 7 months ago

Was trying to get mio to build and run on the 3ds, using its poll backend, such that crates like reqwest and the literal thousands of libraries that depend on tokio's net feature would run, but i ran into this issue, just asking if it's to report to upstream, and if so, we should check whether other definitions are wrong, such that they can be fixed all at once:

this is sockaddr_in in rust: https://github.com/rust-lang/libc/blob/a0f5b4b21391252fe38b2df9310dc65e37b07d9f/src/unix/newlib/horizon/mod.rs#L34-L38

and this is the devkitpro definition: https://libctru.devkitpro.org/structsockaddr__in.html

    pub struct sockaddr_in {
        pub sin_family: ::sa_family_t,
        pub sin_port: ::in_port_t,
        pub sin_addr: ::in_addr,
+       pub sin_zero: [::c_char; 8],
    }
Meziu commented 7 months ago

Uhm, I thought we had accounted for those definitions already… If we can find more issues in the bindings we could push everything through with one PR, otherwise it’s fine to just merge this one change directly to libc.

FenrirWolf commented 7 months ago

There's at least one more problem that I was planning on making an issue for: libctru changed the definition for hostent some time ago, and both libc and std are using the old one still

adryzz commented 7 months ago

yeah, we should create some patches to fix libc/std all at once. i'll try checking if other definitions are wrong

adryzz commented 7 months ago

uhh one problem: i found this: https://github.com/rust-lang/libc/pull/2725, which is the PR that created this problem. how do we proceed?

edit: for more info, this branch of mio adds Horizon OS support, and doesn't build without the extra bytes

Meziu commented 7 months ago

uhh one problem: i found this: rust-lang/libc#2725, which is the PR that created this problem. how do we proceed?

Wow, i had completely forgotten about that! Do we know whether the original “faulty checks” issue is still present? I’m a bit unsure on how to tackle this problem.

Edit: we could turn off the checks in std (or make custom ones for Horizon), but that would create a bit of difference with the rest of the implementations that we’d have to maintain (would they even accept it?)

Meziu commented 2 months ago

Opened the above-mentioned PR in libc and also prepared a std patch in my fork to fix the check issues (tried and tested with network-sockets).

Due to the usual disconnect between libc releases and the (new?) objectives to release a 1.0 libc version, I'll hold off from making a PR with the patch to std for now.

Meziu commented 2 months ago

I also want to link to this small thread me and Ian had, since we discussed looking for alternatives to modifying the std size check.