miow assumes that the memory layout of std::net::SocketAddrV{4,6} matches libc::sockaddr, but this can't be assumed. std makes no such promise to the outside world.
The offending code is here:
|
fn socket_addr_to_ptrs(addr: &SocketAddr) -> (*const SOCKADDR, c_int) { |
|
match *addr { |
|
SocketAddr::V4(ref a) => ( |
|
a as *const _ as *const _, |
|
mem::size_of::<SOCKADDR_IN>() as c_int, |
|
), |
|
SocketAddr::V6(ref a) => ( |
|
a as *const _ as *const _, |
|
mem::size_of::<SOCKADDR_IN6_LH>() as c_int, |
|
), |
|
} |
|
} |
Some other crates made the same assumptions, and they are being fixed in tokio-rs/mio#1388, rust-lang/socket2#120 and deprecrated/net2-rs#106.
Until this is fixed and published it kind of blocks moving these fundamental network types into core and also stops them from having const fn constructors. See this PR on std for reference: rust-lang/rust#78802.
miowassumes that the memory layout ofstd::net::SocketAddrV{4,6}matcheslibc::sockaddr, but this can't be assumed.stdmakes no such promise to the outside world.The offending code is here:
miow/src/net.rs
Lines 459 to 470 in c863739
Some other crates made the same assumptions, and they are being fixed in tokio-rs/mio#1388, rust-lang/socket2#120 and deprecrated/net2-rs#106.
Until this is fixed and published it kind of blocks moving these fundamental network types into
coreand also stops them from havingconst fnconstructors. See this PR onstdfor reference: rust-lang/rust#78802.