I'm experiencing sporadic EINVAL result when I call writev
syscall with a nonblocking TCP socket.
The error happens at this line of doctest
I don't see any errors when I run this test in Linux container.
The test sends a static string "test" compiled into binary.
The tested runtime allocates io_vec
structure with a single buffer inside a loop until the whole buffer is fully sent.
The io slice is captured in a task future (the only one in the test) that is allocated on the heap by async executor. The future is desugared into a state machine that has scopes corresponding to async functions nested in the task future. Rust compiler drops the io slice in the end of send
function scope. This happens after each successfully finished write (when syscall result is not EAGAIN).
The runtime retries writev
syscall when kqueue driver signals that the socket file descriptor is readable.
I get the EINVAL error in about 25% of test runs.
Environment: macOS Ventura 13.5.2, Intel CPU.