Repository navigation
fix(libkernel): answer a zero-length recvmsg on a stream socket as recv does - #24944
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the review supports merging based on the inspected implementation and tests.
What I ran
Reviewed head 7db64acc9a13096674e23d64bc18c3e19fa49877. No commands or tests were run during this review; author-reported CI results are not treated as review runs.
Results
| Check | Result | Note |
|---|---|---|
| Changed-line review | passed | All added lines inspected |
| Test execution | not run | No local test run |
| Author-reported CI | not run | Windows and Linux results in the description |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run; macOS and physical-console behavior were not independently verified. All three changed files listed in the manifest were read, and none were excluded. Targeted context in Udp.cpp and GuestTcp.cpp was also read.
To get this to a good state
Nothing is required.
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 7db64acc9a:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_tcp_testsbuilt cleanly. - CTest (
guest_tcp):1/1 Test #5962: guest_tcp ........................ Passed 0.61 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #5962: guest_tcp ........................Subprocess aborted***Exception: 0.56 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified core/libs/prx/libkernel/Socket/src/Udp.cpp recvmsg_nid_postfix handles empty stream sockets (type == 1 && total == 0 && !passing) via ReceiveAnsweredHere, returning ENOTCONN (57) when unconnected and 0 when connected.
- Verified that when control messages are passed (passing is true) on Unix stream sockets, emptyStream is false and control delivery proceeds via the host.
- Verified that shut sockets (!shut check) bypass ReceiveAnsweredHere and proceed through existing shutdown handling returning 0.
- Verified core/libs/tests/GuestTcp.cpp exercises recvmsg with zero-length iovec on unconnected and connected stream sockets with and without MSG_DONTWAIT, and after queueing data with MSG_PEEK.
- Verified docs/dev/debt/changes/fix-libkernel-recvmsg-zero-length-stream.md technical debt fragment format, documentation of FreeBSD 11.4 soreceive_generic semantics, and strict AGENTS.md compliance.
Looks Good To Me
…cv does recv and recvfrom answer a zero-length receive on a stream socket without the host: 0 when it is connected, ENOTCONN when it is not, as FreeBSD 11.4's soreceive_generic does when nothing is queued. recvmsg asked the host instead, after waiting for the socket to be readable, so on an empty connected socket it failed with EAGAIN under MSG_DONTWAIT or a non-blocking socket and blocked otherwise, and an unconnected socket did not get ENOTCONN. recvmsg now takes the same answer before waiting, except on a Unix stream socket with a control buffer, where FreeBSD delivers queued control messages and the host still answers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7db64ac to
14bebd0
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The reviewed change at head 14bebd06fc136c93c5943daf514f11c9ab9c5b84 skips the host receive for zero-length stream recvmsg cases that can be answered locally, while preserving the host path when Unix control messages may be delivered; the inspected code and added cases support that behavior.
What I ran
No commands or tests were run. I read the prepared description, commits, manifest and diff, and inspected the changed code, its helper, test cases and debt fragment through repo_read.py.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Three changed files read |
| Tests | not run | Author reported Windows and Linux runs |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run tests, verify the author-reported workflow, or test macOS or console behavior. All three files marked reviewed in the manifest were read; no files were excluded.
To get this to a good state
Nothing is required.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
What
recvandrecvfromanswer a zero-length receive on a stream socket without the host: 0 when it is connected,ENOTCONNwhen it is not, as FreeBSD 11.4'ssoreceive_genericdoes when nothing is queued.recvmsgasked the host instead, afterWaitForTransfer, so on an empty connected socket it failed withEAGAINunderMSG_DONTWAITor on a non-blocking socket and blocked otherwise, and an unconnected socket did not getENOTCONN; the libkernel debt file records this ("asks the host in the stream cases").recvmsgtakes the sameReceiveAnsweredHereanswer before waiting when a stream socket's iovecs total zero bytes.soreceive_genericgoes on to deliver the queued control messages even for a zero-length request.GuestTcp.cpp'sReceiveAnsweredWithoutTheHostgets therecvmsgcases beside therecvandrecvfromones:ENOTCONNon an unconnected socket with and withoutMSG_DONTWAIT, 0 on an empty connected socket with and without it, and 0 with data queued, the data still there afterwards. The debt fragment rewrites the entry to coverrecvmsgand records the control-buffer case and the pending socket error these answers do not return.Tested
Commit 14bebd0 on
mainb1ef52c, Release, in a workflow on my fork: https://github.com/Dr-Coconut/AnyPS5/actions/runs/45036318072 (the run on the first version, 7db64ac on 26194f0, gave the same results: https://github.com/Dr-Coconut/AnyPS5/actions/runs/44901177525)windows-latest, image windows-2025-vs2026, WinLibs GCC 15.2.015.2.0posix-14.0.0-ucrt-r7) and Linux (GitHub-hostedubuntu-latest, image ubuntu-26.04, GCC 15.2.0), with the change:guest_tcp,guest_udp,guest_socket_pairandguest_kernel_socket_dontwaitpass on both.Udp.cpprestored tomainand the new cases kept, on both:guest_tcpaborts (Windows0xc0000409, LinuxSubprocess aborted); the other three pass.Not run on macOS. No title tested.
tools/check_conventions.pypasses, andtools/debt_fold.py --checkaccepts the fragment. Rebased ontomainafter #23341 changedReceiveShuttoReceiveEndedon the line before this change; the branch keepsReceiveEnded.tools/pr_overlap.py --branchmerged 26 open pull requests that share files with this branch and reported #18197, which adds the arrival-time setup betweenstampsand the condition changed here, so they overlap textually. It could not compare seven that conflict withmain; compared by hand, #8605 changesGuestSockets::Stat, #11896 replaces the host call inside the block this skips, #22048 adds a check inside that block, and #12682, #12688, #12700 and #12965 rework blocking connects and waits on Windows without touching these lines.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code