fix(libkernel): drop the datagram whose recv faulted on macOS, as recvfrom does #25134
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25134"
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 Gonic0 on 2026-11-21T17:32:42Z.
What
guest_udpfails on macOS since2c7575b2ea(fix(libkernel): check the send and recv buffers as sendto and recvfrom do), atGuestUdp.cpp:669: after arecvon a datagram socket fails withEFAULT, the nextrecvmust return the next datagram, as FreeBSD drops the one whose copy out faulted.On macOS the faulted datagram stays queued.
6ad2973348(fix(libkernel): drop a datagram whose receive faulted on macOS) handles that inrecvfromwithDropFaultedDatagram, butrecvtakes its own path to::recvand returnedEFAULTwithout the drop, so the nextrecvgot the faulted datagram again.recvnow callsDropFaultedDatagramafter anEFAULTon macOS, asrecvfromdoes.recvmsgreceives into a host buffer before copying to the guest, so it already consumes the datagram. Linux and Windows are unchanged.Tested
macOS 27.3, Apple M5 Pro, Apple clang, x86-64 Release under Rosetta 2,
BUILD_TESTING=ON. Tree:main6d55d9b269plus #17425, #11049 and #25116, whichmainstill needs to build on macOS (#24117).mainhas since moved to0e001115a9without changes toUdp.cpporGuestUdp.cpp; this branch is rebased onto it.guest_udp: fails without this change (Requireat line 669, found by temporarily printing the failing line); passes 5 of 5 runs with it.ctest -R '(udp|socket|tcp|sce_net|poll|recv|send|net_)' -j6, 126 tests: 5 fail without this change, 4 with it. The remaining four (guest_sce_net,guest_socket_options,guest_poll,guest_socket_port_zero) fail the same way with and without it and are listed in #24117.#ifdef __APPLE__.tools/check_conventions.pypasses.tools/pr_overlap.py --branchcould not compare five open pull requests that touchUdp.cppbecause they conflict withmain; compared by hand:recv_nid_postfix(ReceiveEnded, theWSAEMSGSIZEline), #11896 replaces the end ofrecv_nid_postfixwith aReceivehelper, and #18190 movesrecv_nid_postfix. Whichever merges later rebases; neither change depends on the other.recv_nid_postfix.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T00:34:05Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code follows the existing macOS
recvfromhandling and preserves the mapped error return.What I ran
Reviewed head
d37121dfbea137493e75c3c29668fc7907df0b17. No commands or tests were run. The author reports macOS tests and convention checks; these were not run by me.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests, builds, and runtime behavior were not independently verified. The only changed file,
core/libs/prx/libkernel/Socket/src/Udp.cpp, was read at the changed function, helper, and relatedrecvfrompath. No files were excluded by the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-12-01T00:21:59Z.
Review: APPROVED
Confirmed on macOS 15.
Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta,
BUILD_TESTING=ON. These are the OS and compiler generation of themacos-15runner.Tree:
main93d64f2d1e+ the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (maindoes not build on macOS without them, see #28168), + #22091, #28369, #28075, #28076, #28284, then #17878, #20161, #25134, #26806, #22932, #28373, #27828, #27950, #27582, #24311 merged one after another. All merged cleanly.guest_udpd37121dfbeFull
ctest -j 6after all of them: 7047/7066 pass. Compared with the run before the second group of merges, no test fails that passed before.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:56:16Z.
Review: COMMENTED
The Darwin
EFAULTpath callsrecva second time to discard the faulted datagram. The original receive and the discard are separate operations, so another reader of the socket can consume that datagram before the discard and cause this call to drop the following one. Please keep a faulting call's packet consumption within one receive operation or coordinate the receive paths so they cannot discard another reader's packet.The integrated Linux
guest_socket_optionsandguest_socket_port_zerocontrols passed. The new receive behavior is specific to Darwin and still needs verification there.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T20:56:58Z.
Review: APPROVED
Reviewed — looks good
The change applies the existing macOS faulted-datagram handling to
recvand records its documented race; I found no blocking defects in the reviewed files.What I ran
Reviewed head
a1ee7b1df4d631373867268fb2f4f7a2ecd1f7ddagainst basemain; no merged-preview check. I usedrepo_read.pyto inspect the changed lines,DropFaultedDatagram, and the correspondingrecvfromhandling. No tests or builds were run. The author reports macOS test results in the PR description; these were not independently run.Results
Negative control
Not run; no test was executed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Udp.cppat the reviewed head adds the macOS EFAULT handling;DropFaultedDatagramskips non-datagram sockets andMSG_PEEKand uses a non-blocking receive.Not verified
No tests or builds were run, and macOS, Linux, and Windows behavior was not independently exercised. I read both changed files listed under
reviewedinfiles.json; that list contains no excluded files.To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.