fix(libSceNet): count only datagram bytes in sceNetIoctl FIONREAD on macOS #10628
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10628"
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 maximilianfv on 2026-10-24T13:32:50Z.
What
On macOS,
FIONREADon a datagram socket counts more than the queued payload, sosceNetIoctl(socket, FIONREAD)on asceNetSocketUDP socket reported 37 after one 5-byte datagram, whereguest_sce_netexpects 5, as Linux reports. On macOS,sceNetIoctlnow asks a non-stream socket forSO_NREAD, the size of the next datagram, and keepsioctl(FIONREAD)for stream sockets. libkernel's own sockets already do this on macOS (QueuedBytesinlibkernel/Socket/src/Udp.cpp, from #7850 by mugurc), anddocs/dev/debt/libkernel.mdrecords it. ThesceNetIoctlentry indocs/dev/debt/libSceNet.mdnow says the same for macOS. Linux and Windows are unchanged.Prior art: iamthehimansh made the same change to
sceNetIoctlin commitb2c0e64753(2026-10-23) of the closed macOS port #8658, so he is credited as co-author on the commit. That commit is not in the PRs #8658 was split into (#10362, #10419). The two differ in small ways: that version sends onlyNET_SOCK_DGRAMsockets toSO_NREADand has a code comment and no debt entry; this one sends every non-stream socket and updates the debt entry. #7201 (marion909) and #7332 (ycarogabriel-lgtm) useSO_NREADonly in libkernel'sioctl, not in libSceNet. #9932 and #9948 (ntamas94) readFIONREADinsceNetGetSockInfo, a different function.What the console reports is a separate question: #9932 (ntamas94) measured on a PS4 Pro that
sceNetGetSockInfo's receive queue length counts each queued datagram's payload plus 16 bytes, as FreeBSD 11.4's receive buffer does. So this change matches neither the console nor plain macOS; it follows libkernel's sockets and the test. The debt entry now says so.Tested
Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2.
mainalone does not build on macOS, so I tested in a tree made of mugurc's macOS series (ci/macos-series-2, 27e968974) merged withmainat1e20650e84, plus other macOS fixes that are not yet open PRs and #9231 (7c5d97324). Only this change differed between the two runs.ctest -R '^(guest_sce_net|guest_inet_address|guest_net_.*|guest_datagram_.*|net_dontwait_.*|guest_socket_error|guest_udp)$'(21 tests): 20 pass both with and without this change.guest_sce_netaborts in both runs, at a different check each time:GuestSceNet.cpp:845. After one 5-bytesceNetSendtoto itself and a readable poll,sceNetIoctl(socket, 0x4004667f, ...)gives 37 where the test expects 5 (value read with lldb at the abort).GuestSceNet.cpp:1930:sceNetResolverStartNtoa6of"127.0.0.1"must fail with0x804101E1. This is a separate resolver gap.I found both stops with lldb on a
-O0rebuild. The test reaches theFIONREADcheck only with #9231 (Gonic0) applied, because #9231 fixes an earlier stop atGuestSceNet.cpp:175. This change does not need #9231's code; only the test needs it to get that far.Not tested on Linux or Windows; the code there is unchanged.
After #10572 merged I rebased onto
mainfccc63319d. Only the debt-file context changed, the code is byte-identical, and I did not re-run the tests.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-10-24T13:39:24Z.
Review: APPROVED
Reviewed exact head
57333d34904a5f01b8f2b0d480265960cf3ea542. The macOS-only branch preserves streamFIONREADbehavior and usesSO_NREADfor non-stream sockets, matching the platform-specific mismatch reproduced in the PR body and the existing guest assertion for a 5-byte datagram. Linux and Windows code paths are unchanged. The debt text now records the platform behavior and distinguishes the PS4 ProsceNetGetSockInfomeasurement from thissceNetIoctlcall.git diff --check upstream/main...HEADandpython3 tools/check_conventions.py --base upstream/main --head HEADpass on this exact head. Hosted eligibility, conventions, intake, and labels pass; product test jobs were skipped. The macOS 21-test run and before/after debugger evidence are author-reported; I did not independently run macOS. I found no blocking issue in this focused platform fix.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T13:48:53Z.
Review: CHANGES_REQUESTED
Follow-up on the new overlap check at exact head
57333d34904a5f01b8b2d0b480265960cf3ea542: I manually compared the shareddocs/dev/debt/libSceNet.mdhunk with #10572.git merge-tree --write-tree upstream/pr/10572 upstream/pr/10628reports a content conflict in that file: both PRs edit the adjacentsceNetUsleep/sceNetIoctlentries in one hunk. The two code changes are distinct, and the conflict is straightforward to resolve by retaining both updated entries, but the PRs still need an agreed merge order and the dependent PR should recordDepends on: #Nas required by CONTRIBUTING. The current checklist saysDepends on: none.Please coordinate with #10572's author and record the agreed order/dependency. My earlier approval covered the implementation; this review requests changes only for the unresolved documentation merge coordination. The newly posted macOS measurements on #10628 are useful additional host evidence.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T14:12:43Z.
Review: APPROVED
Follow-up on exact head
57333d34904a5f01b8f2b0d480265960cf3ea542. The merge-order blocker is resolved: #10572's author confirms it lands first, and this PR now recordsDepends on: #10572and will rebase to retain both debt entries. My prior code review remains applicable: the macOS-only path usesSO_NREADfor non-stream sockets while preserving streamFIONREAD; Linux and Windows are unchanged. The author reports 20 of 21 focused tests pass in both runs; the oneguest_sce_netstop is a separate resolver expectation, and the targetFIONREADassertion passes only with this change. Hosted policy checks pass and product builds were skipped. I did not independently run the macOS test suite. No blocker remains.