Skip to content

wasip3: sockets-udp-send::test_wrong_address_family does not return InvalidArgument for cross-family send #13398

@cataggar

Description

@cataggar

Summary

The upstream wasi-testsuite fixture wasm32-wasip3/sockets-udp-send (tests/rust/wasm32-wasip3/src/bin/sockets-udp-send.rs's test_wrong_address_family) panics on wasmtime 44.0.1 (first stable release with -Sp3 support). The fixture creates a UDP socket bound to one address family and sends a packet to an address of the other family, expecting ErrorCode::InvalidArgument. wasmtime returns something other than Err(InvalidArgument) and the matches! assertion panics.

Reproduction

cd tests/rust/wasm32-wasip3 && make build && cd -
wasmtime -Wcomponent-model-async -Sp3,inherit-network \
    tests/rust/testsuite/wasm32-wasip3/sockets-udp-send.wasm

Output (trimmed):

thread '<unnamed>' (1) panicked at src/bin/sockets-udp-send.rs:21:5:
assertion failed: matches!(result, Err(ErrorCode::InvalidArgument))
…
   12:   0x44e2 - sockets_udp_send…!sockets_udp_send…::test_wrong_address_family::{closure#0}
…
    1: wasm trap: wasm `unreachable` instruction executed

The asserting code (tests/wasi-testsuite tests/rust/wasm32-wasip3/src/bin/sockets-udp-send.rs:12-22):

async fn test_wrong_address_family(family: IpAddressFamily) {
    let sock = UdpSocket::create(family).unwrap();

    let addr = match family {
        IpAddressFamily::Ipv4 => IpSocketAddress::localhost(IpAddressFamily::Ipv6, 0),
        IpAddressFamily::Ipv6 => IpSocketAddress::localhost(IpAddressFamily::Ipv4, 0),
    };

    let result = sock.send(vec![0; 1], Some(addr)).await;
    assert!(matches!(result, Err(ErrorCode::InvalidArgument)));   // panics on wasmtime 44.0.1
}

Cross-runtime parity

The same fixture passes on the WAMR-Zig WASIp3 host (40 / 40 wasm32-wasip3 fixtures pass, this one included). The WAMR host validates the destination address family against the socket's family before reaching the kernel and returns Err(InvalidArgument) on the mismatch. wasmtime 44 either passes the send through to the kernel (which fails with EINVAL / EAFNOSUPPORT and gets mapped to a different ErrorCode variant) or accepts it.

Why this matters

One of four wasm32-wasip3 fixtures that fail on stock wasmtime 44.0.1 but pass on the WAMR-Zig host; tracked in cataggar/wamr#583 C1.

Environment

  • wasmtime 44.0.1 (f302ebd6b 2026-04-30)
  • wasi-testsuite 40c1f7d tests/rust/testsuite/wasm32-wasip3/sockets-udp-send.wasm
  • Linux 6.x aarch64

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