libkernel: recv after shutdown(SHUT_RD) fails with EPIPE and a zero-length recv on a stream socket blocks (Windows) #8491
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T13:46:56Z.
Repro
Windows host, connected stream pair. (1)
shutdown(a, SHUT_RD), thenrecv(a, buf, 8, 0). (2)recv(a, buf, 0, 0)with nothing queued.Expected (FreeBSD 11.4
soreceive_generic, sys/kern/uipc_socket.c): (1) 0 (SBS_CANTRCVMORE, Z.1556-1562); (2) 0 without waiting (uio_resid == 0, Z.1575-1578),ENOTCONNon a socket that is not connected (Z.1566-1572).Actual: (1) -1/EPIPE (32), the Winsock
WSAESHUTDOWN; (2) the call blocks until data arrives, as Winsock does for a zero-byte receive.Test:
core/libs/tests/GuestTcp.cpp(ReceiveAnsweredWithoutTheHost, new; aborts before the fix).Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/recv-after-shutdown-and-empty
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-21T09:46:00Z.
Linux results distinguish the two parts of this report: zero-length receives also block here; the empty
SHUT_RDcase returns EOF rather than Windows'EPIPE. There is an additional queued-data distinction below.Tested unchanged upstream
mainb5d763770a8e932b35db9bea1c415e7e0ac50a22in a separate validation checkout. Environment: Debian GNU/Linux 13.7 (trixie), x86-64, kernel7.2.9-x64v3-xanmod1, AMD Ryzen 5 7640HS, GCC/G++ 15.2.0, CMake 3.31.6/Ninja. Full project configuration:Release,BUILD_TESTING=ON,ANYPS5_RELINKER_ONLY=OFF,ANYPS5_USE_SYSTEM_DEPS=OFF; rebuiltlibc,libkernelandlibkernel_sys. Temporary probes linked directly to these freshly built, unpatched runtime libraries, as the repository runtime tests do. No production source changes.Reproduction: fresh real IPv4 TCP loopback pair for each case, using the guest
socket/bind/listen/connect/acceptAPIs. Called bothrecv_nid_postfixandrecvfrom_nid_postfixwith a valid buffer. Results were the same for both APIs:MSG_DONTWAIT(0x80)EAGAIN)0x80ENOTCONN)shutdown(receiver, SHUT_RD), empty stream, receive up to 8 bytesshutdown(receiver, SHUT_RD), peer then sendsx, receive up to 8 bytesxFor
recvfrom, successful cases set the sender-address length to 0. A focused syscall trace confirms the last result comes from forwarding to Linux:Thus zero-length blocking is not Windows-only, while the post-shutdown
EPIPEitself did not reproduce on this Linux setup. The delayed-send control establishes that the zero-length call waits for readiness and does not consume the byte. The last row also differs from #8492's proposed unconditional EOF after guest receive shutdown.Existing
guest_tcppasses; it does not cover these zero-length cases on main. Scope: unchanged-main observations only, not validation of #8492 or an independent measurement of console/FreeBSD semantics.recvmsg, Windows, GPU and title execution were not tested.AI-assisted: yes (Codex); I am responsible for the reported investigation and results.