fix(libkernel): answer a zero-length recvmsg on a stream socket as recv does #24944
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24944"
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 Dr-Coconut on 2026-11-21T12:02:55Z.
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
14bebd06fconmainb1ef52c45e, Release, in a workflow on my fork: https://github.com/Dr-Coconut/AnyPS5/actions/runs/45036318072 (the run on the first version, 7db64acc9a on26194f0fcf, 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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T12:11:59Z.
Review: APPROVED
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
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.cppandGuestTcp.cppwas also read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T12:17:52Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
7db64acc9a:tools/check_conventions.pypassed.guest_tcp_testsbuilt cleanly.guest_tcp):core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T17:26:22Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at head
14bebd06fc136c93c5943daf514f11c9ab9c5b84skips the host receive for zero-length streamrecvmsgcases 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
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.