libkernel: recv, recvfrom and recvmsg fail MSG_WAITALL with EOPNOTSUPP where FreeBSD 11.4 waits for the whole request #8473

Closed
opened 2026-10-20 13:16:56 +00:00 by xXPBSXx · 1 comment
xXPBSXx commented 2026-10-20 13:16:56 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T13:16:56Z.


Repro

Windows host. A connected stream socket with 4 bytes queued and 4 more arriving 150 ms later: recv(s, buf, 8, 0x40).
Expected (FreeBSD 11.4): returns 8 once the buffer is full (soreceive_generic keeps waiting while MSG_WAITALL is set and uio_resid > 0, uipc_socket.c:1855-1860; MSG_WAITALL is 0x40, sys/sys/socket.h:433); returns the bytes received when the peer closes first.
Actual: -1 with EOPNOTSUPP (45): recv_nid_postfix, recvfrom_nid_postfix and recvmsg_nid_postfix accept only MSG_PEEK and MSG_DONTWAIT.
Test: core/libs/tests/GuestTcp.cpp (WaitAllReceivesTheWholeRequest, new; aborts before the fix).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/recv-msg-waitall
AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5942349853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8473). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T13:16:56Z. --- ### Repro Windows host. A connected stream socket with 4 bytes queued and 4 more arriving 150 ms later: `recv(s, buf, 8, 0x40)`. Expected (FreeBSD 11.4): returns 8 once the buffer is full (`soreceive_generic` keeps waiting while `MSG_WAITALL` is set and `uio_resid > 0`, uipc_socket.c:1855-1860; `MSG_WAITALL` is 0x40, sys/sys/socket.h:433); returns the bytes received when the peer closes first. Actual: -1 with EOPNOTSUPP (45): `recv_nid_postfix`, `recvfrom_nid_postfix` and `recvmsg_nid_postfix` accept only `MSG_PEEK` and `MSG_DONTWAIT`. Test: `core/libs/tests/GuestTcp.cpp` (`WaitAllReceivesTheWholeRequest`, new; aborts before the fix). Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/recv-msg-waitall AI-assisted (Claude Code).
Filip722 commented 2026-10-21 09:45:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-21T09:45:53Z.


Confirmed on Linux: the MSG_WAITALL rejection is shared, including recvmsg (listed as untested in #8474).

Tested unchanged upstream main b5d763770a8e932b35db9bea1c415e7e0ac50a22 in a separate validation checkout. Environment: Debian GNU/Linux 13.7 (trixie), x86-64, kernel 7.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; rebuilt libc, libkernel and libkernel_sys. Temporary probes linked directly to these freshly built, unpatched runtime libraries, as the repository runtime tests do. No production source changes.

Reproduction: created a real IPv4 TCP pair over 127.0.0.1 using the guest socket APIs, sent "abcd", scheduled "efgh" 150 ms later, then requested 8 bytes with guest flag 0x40. Ran each API in a fresh process; recvmsg used the existing tests' 48-byte guest msghdr layout and one 8-byte iovec.

API Actual result with 0x40 Following receive after the sender joined
recv_nid_postfix -1, guest errno 45 (EOPNOTSUPP), immediately 8 bytes: abcdefgh
recvfrom_nid_postfix -1, guest errno 45, immediately 8 bytes: abcdefgh
recvmsg_nid_postfix -1, guest errno 45, immediately 8 bytes: abcdefgh

Control: the same three probes with flags 0 each returned 4 bytes (abcd); after joining the sender the remaining 4 bytes were efgh. Thus the connected transport works and the rejected calls did not consume the data. This exercises the real guest flag check in Socket/src/Udp.cpp, where GuestReceiveFlags currently contains only GuestPeek | GuestDontWait.

Existing guest_tcp, guest_socket_pair and guest_recvmsg_memory also pass on this build; those passes do not cover acceptance of 0x40.

Scope: reproduces the defect on unchanged main; I did not apply/test #8474. Blocking IPv4 loopback only; no nonblocking/peek combinations, console, Windows, GPU or title execution tested.

AI-assisted: yes (Codex); I am responsible for the reported investigation and results.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312972706 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8473#issuecomment-6312972706). Originally posted by [Filip722](https://github.com/Filip722) on 2026-10-21T09:45:53Z. --- Confirmed on Linux: the `MSG_WAITALL` rejection is shared, including `recvmsg` (listed as untested in #8474). Tested unchanged upstream `main` **`b5d763770a8e932b35db9bea1c415e7e0ac50a22`** in a separate validation checkout. Environment: Debian GNU/Linux 13.7 (trixie), x86-64, kernel `7.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`; rebuilt `libc`, `libkernel` and `libkernel_sys`. Temporary probes linked directly to these freshly built, unpatched runtime libraries, as the repository runtime tests do. No production source changes. Reproduction: created a real IPv4 TCP pair over `127.0.0.1` using the guest socket APIs, sent `"abcd"`, scheduled `"efgh"` 150 ms later, then requested 8 bytes with **guest** flag `0x40`. Ran each API in a fresh process; `recvmsg` used the existing tests' 48-byte guest `msghdr` layout and one 8-byte iovec. | API | Actual result with `0x40` | Following receive after the sender joined | |---|---|---| | `recv_nid_postfix` | -1, guest errno 45 (`EOPNOTSUPP`), immediately | 8 bytes: `abcdefgh` | | `recvfrom_nid_postfix` | -1, guest errno 45, immediately | 8 bytes: `abcdefgh` | | `recvmsg_nid_postfix` | -1, guest errno 45, immediately | 8 bytes: `abcdefgh` | Control: the same three probes with flags `0` each returned 4 bytes (`abcd`); after joining the sender the remaining 4 bytes were `efgh`. Thus the connected transport works and the rejected calls did not consume the data. This exercises the real guest flag check in `Socket/src/Udp.cpp`, where `GuestReceiveFlags` currently contains only `GuestPeek | GuestDontWait`. Existing `guest_tcp`, `guest_socket_pair` and `guest_recvmsg_memory` also pass on this build; those passes do **not** cover acceptance of `0x40`. Scope: reproduces the defect on unchanged main; I did not apply/test #8474. Blocking IPv4 loopback only; no nonblocking/peek combinations, console, Windows, GPU or title execution tested. AI-assisted: yes (Codex); I am responsible for the reported investigation and results.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#8473
No description provided.