fix(libkernel): report a reset stream socket polled for no event as hung up on macOS #20161
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20161"
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 imellag on 2026-11-14T18:40:12Z.
What
guest_pollaborts on macOS onmainin the reset-stream case that #11247 added from a PS5 measurement: after the peer resets the connection,pollasking for no event must return 1 withPOLLHUP. XNU'spollnever reports anything for a socket polled for no event, even after a reset, while the same socket polled forPOLLINreportsPOLLIN|POLLHUP. A host program on macOS 27.2 shows it (peer closed withSO_LINGER{1, 0}):On macOS, a guest stream socket polled for no event is now asked again with
POLLINat a zero timeout after each host wait, and only thePOLLHUPorPOLLERRof that answer is kept. That answer goes through the existingClosedStreamEvents, so a peer's plain close (one direction ended) still reports nothing and does not wake the call, as on FreeBSD; a reset reportsPOLLHUP. The host wait itself still asks for no event, so readable data does not end the wait early. A socket polls in slices of 10 ms, so a reset during a wait is seen up to 10 ms late; with a zero timeout it is seen at once. Other hosts, libSceNet sockets lent topolland every socket that asks for an event are unchanged.The macOS socket debt entry said "a call that asks for no event gets nothing, where FreeBSD reports
POLLHUP"; it now records the second query and its delay (still under 1000 characters).Tested
macOS 27.2, Apple M4 Pro, x86-64 Release under Rosetta 2,
main80b0bdf264.guest_pollonmain: aborts at the no-event check after the reset (thePOLLINandPOLLIN|POLLOUTchecks around it already pass). With the change: passes 3 of 3 runs.ctest -R "poll|socket|select|kevent|kqueue|equeue|sce_net|net_ctl|udp|tcp|linger|connect": 119 of 123 pass; the 4 failures (guest_refused_connect,guest_sce_net,guest_socket_options,guest_socket_port_zero) fail the same way onmainon this Mac. In one of three parallel (-j6) runsguest_socket_read_writealso failed; it passes 6 of 6 runs alone and only polls for requested events, which this change does not touch.python3 tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pyconfirms no overlap; it could not comparedocs/dev/debt/libkernel.mdwith older PRs that conflict withmain, and #17853 (Linux pipes) also editsUdp.cppin a different function.Not run on Windows or Linux; the change is inside
#ifdef __APPLE__.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)Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-16T12:14:01Z.
Review: COMMENTED
Tested on macOS 27.2, Apple Silicon (M4), full build (x86-64 under Rosetta 2). This PR was merged alone onto
main04f7633c01withgit merge --no-ff. I ran the 56 socket and net tests (guest_socket_*,guest_poll,guest_refused_connect,guest_sce_net,guest_net_*,guest_kernel_socket*) three times onmainand three times with this PR.guest_pollfails in all three runs onmainand passes in all three runs with this PR.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:31:13Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
fd83adbb17dc8d420b13149d468eaf67bb6d768bagainst the prepared diff. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Did not run tests or independently verify the reported macOS behavior. No files were excluded; both files listed as reviewed in the manifest were read.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-12-01T00:21:57Z.
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_pollfd83adbb17Full
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:15:28Z.
Review: COMMENTED
The second poll is scoped to the macOS sockets with an empty native event mask. Please move the debt change into a fragment under
docs/dev/debt/changes/so it can be applied without overwriting newer socket debt entries. I reviewed the code path from Linux.AI-assisted: yes.
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.