Skip to content

udp: OSX10.15 crash in decode_recv expecting IPv4 or v6 #2383

@mxinden

Description

@mxinden

quinn-udp's decode_recv in unix.rs expects the source address to be either an IPv4 or an IPv6, see unreachable! below:

quinn/quinn-udp/src/unix.rs

Lines 760 to 782 in 3e302f7

let addr = match libc::c_int::from(name.ss_family) {
libc::AF_INET => {
// Safety: if the ss_family field is AF_INET then storage must be a sockaddr_in.
let addr: &libc::sockaddr_in =
unsafe { &*(&name as *const _ as *const libc::sockaddr_in) };
SocketAddr::V4(SocketAddrV4::new(
Ipv4Addr::from(addr.sin_addr.s_addr.to_ne_bytes()),
u16::from_be(addr.sin_port),
))
}
libc::AF_INET6 => {
// Safety: if the ss_family field is AF_INET6 then storage must be a sockaddr_in6.
let addr: &libc::sockaddr_in6 =
unsafe { &*(&name as *const _ as *const libc::sockaddr_in6) };
SocketAddr::V6(SocketAddrV6::new(
Ipv6Addr::from(addr.sin6_addr.s6_addr),
u16::from_be(addr.sin6_port),
addr.sin6_flowinfo,
addr.sin6_scope_id,
))
}
_ => unreachable!(),
};

For some (yet) unknown reason, Firefox crashes on some MacOS X 10.15 instances on exactly the above assumption.

Reported in https://bugzilla.mozilla.org/show_bug.cgi?id=1987606.

Crash reports (66 so far): https://crash-stats.mozilla.org/signature/?product=Firefox&signature=quinn_udp%3A%3Aimp%3A%3Adecode_recv

I have to investigate more. Opening up here for tracking for now.

Whether we find the root cause or not, it might be worth being a bit more defensive here, only crashing in debug mode, returning an error in release mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions