Skip to content

wasip3: sockets-tcp-connect::test_explicit_bind_addrinuse does not get AddressInUse on second bind #13396

@cataggar

Description

@cataggar

Summary

The upstream wasi-testsuite fixture wasm32-wasip3/sockets-tcp-connect (tests/rust/wasm32-wasip3/src/bin/sockets-tcp-connect.rs's test_explicit_bind_addrinuse) panics on wasmtime 44.0.1 (the first stable release with -Sp3 support). The fixture creates two sockets, binds the first to localhost:0, then asks the kernel for the assigned port and tries to bind a second socket to the same address, expecting ErrorCode::AddressInUse. wasmtime returns something other than Err(AddressInUse) and the matches! assertion panics.

Reproduction

# In a wasi-testsuite checkout at d8c30a7 with wasmtime 44.0.1 on PATH
cd tests/rust/wasm32-wasip3 && make build && cd -
wasmtime -Wcomponent-model-async -Sp3,inherit-network \
    tests/rust/testsuite/wasm32-wasip3/sockets-tcp-connect.wasm

Output (trimmed):

thread '<unnamed>' (1) panicked at src/bin/sockets-tcp-connect.rs:154:5:
assertion failed: matches!(result, Err(ErrorCode::AddressInUse))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `…/sockets-tcp-connect.wasm`
…
   12:   0xbbf1 - sockets_tcp_connect…!sockets_tcp_connect…::test_explicit_bind_addrinuse::{closure#0}
…
    1: wasm trap: wasm `unreachable` instruction executed

The asserting code (tests/wasi-testsuite tests/rust/wasm32-wasip3/src/bin/sockets-tcp-connect.rs):

async fn test_explicit_bind_addrinuse(family: IpAddressFamily) {
    let listener = {
        let bind_address = IpSocketAddress::localhost(family, 0);
        let listener = TcpSocket::create(family).unwrap();
        listener.bind(bind_address).unwrap();   // bind to ephemeral port
        listener
    };

    let listener_address = listener.get_local_address().unwrap();  // ask the kernel for the port
    let client = TcpSocket::create(family).unwrap();

    let result = client.bind(listener_address);   // second bind to the same port
    assert!(matches!(result, Err(ErrorCode::AddressInUse)));   // 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), which suggests the upstream WIT contract is for bind to return Err(AddressInUse) when a second socket tries to bind to a port still held by another socket. wasmtime 44 either lets the second bind succeed (perhaps because SO_REUSEADDR is set on the second socket) or maps the kernel EADDRINUSE to a different ErrorCode variant.

Why this matters

This is one of four wasm32-wasip3 fixtures that fail on a stock wasmtime 44.0.1 install but pass on the WAMR-Zig host; tracked in cataggar/wamr#583 C1 (the cross-runtime parity gate). Filing here so the parity gate can mark it as a documented wasmtime-side delta until a wasmtime fix lands.

Environment

  • wasmtime 44.0.1 (f302ebd6b 2026-04-30) — from curl https://wasmtime.dev/install.sh | bash -s -- --version v44.0.1
  • wasi-testsuite wasi-testsuite-rust-runners-1.0.0 (40c1f7d) tests/rust/testsuite/wasm32-wasip3/sockets-tcp-connect.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