Repository navigation
feat(libkernel): skip the end of file in poll with POLLINIGNEOF on sockets and pipes, as FreeBSD 11.4 does - #27260
Conversation
…ckets and pipes, as FreeBSD 11.4 does poll no longer throws for POLLINIGNEOF on a guest socket, a libSceNet socket or a pipe. As FreeBSD 11.4's sopoll_generic and pipe_poll skip their end-of-file block when the bit is set, POLLHUP is never reported, a hung-up descriptor reports POLLOUT, and POLLIN and POLLRDNORM follow soreadabledata: a stream socket needs its SO_RCVLOWAT bytes queued, a datagram socket a queued datagram, even an empty one, a sequenced-packet socket queued bytes, a listener a pending connection, and a pending socket error keeps the socket readable after the guest's own SHUT_RD. macOS, whose poll does not report a socket error as POLLERR, finds it with a peeking non-blocking recv, which leaves the error pending. A wait that the host ends with only such dropped readiness is resumed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
Changes are required before merge: avoid dereferencing a null socket when a forwarded socket has POLLINIGNEOF readiness and a pending error.
What I ran
Reviewed head e5422a9d7c4d2d7602962ae620ab3686fd5b8255 using repo_read.py to inspect the prepared description, commit summary, manifest, diff, and changed source ranges. No tests or builds were run. The author reports tests and syntax checks in the PR description; those were not run during this review.
Results
| Check | Result | Note |
|---|---|---|
| Prepared diff and changed code | passed | Five changed files inspected |
| Tests and builds | not run | Author-reported checks only |
| Platform coverage | not run | macOS path unconfirmed |
Findings
Blocking
core/libs/prx/libkernel/Socket/src/Udp.cpp:3295can dereference a nullsocket. Forwarded sockets are added toforwardedSockets, but notguestSockets, soguestAt[i]is null for them. If a forwarded socket reports readable readiness whileerrorPendingis true, the code skips the precedingPollDataQueuedbranch and reachessocket->typehere. This can crash polling libSceNet sockets on that path. Guard the socket-specific low-water check or derive the socket type without assuming a guest socket.
Non-blocking
None.
Not verified
- No tests or builds were run; author-reported Windows test results and Linux syntax checks were not independently confirmed.
- macOS behavior is unconfirmed, as the PR description also states.
- The prepared manifest lists five changed files, and all five full texts were readable and inspected.
files.jsonwas not available through the reader, so the excluded-file list was not verified.
To get this to a good state
Guard the socket-specific access at Udp.cpp:3295, then rerun the relevant poll tests, including the forwarded-socket error case.
|
I tested the poll implementation from I found one portability issue in the new forwarded-socket test. It calls One older assertion still stops the full Darwin guest_poll executable. After a TCP reset, a plain poll with On the pending-error review point, the low-water block is guarded by I also tested the complete Darwin integration. Adding the existing #20161 fix for the zero-interest hangup to the shutdown adjustment above made the stock |
MarcZX10 CHANGES_REQUESTED 2026-11-25T16:26Z on e5422a9 (review 6061131544): null dereference of socket at Udp.cpp:3295. Checked at source: lowWater starts at 1 and is raised only inside if (socket) (Udp.cpp:3290-3293), so for a forwarded socket (socket null) lowWater > 1 is false and the && short-circuits before socket->type is read. No defect; RavenCurseBurg reached the same reading in the thread. Fresh PASS: notes/27260-e5422a9d7c.md.
The fixture already closed the receive side. Closing the send side next reaches the same final state on macOS for sockets forwarded through libSceNet. AI-assisted: Codex + GPT-6.2 Astra (xhigh)
|
Thanks, @RavenCurseBurg, for the macOS runs. I cherry-picked the test-only change (eb54118: On the earlier null- |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The reviewed change adds POLLINIGNEOF handling for sockets and pipes; I found no verified blocking defect, but the macOS-specific behavior remains unverified.
What I ran
Reviewed head ad768c99ccfb9e27f179ad6ec013cbc8dd5f4048 against base main. No commands or tests were run in this review; test results in the PR description are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Changed behavior review | passed | Relevant implementation and added lines inspected |
| Test execution | not run | No tests run in this review |
| Windows and Linux behavior | not run | Author reports tests and syntax checks |
| macOS behavior | not run | Author reports no macOS host was available |
Negative control
Not run; no test was executed in this review.
Findings
Blocking
None identified in the code reviewed.
Non-blocking
- The macOS-specific pending-error detection and poll behavior have not been run on macOS. The PR description also notes that CI does not run
guest_pollon macOS. Please verify that path on a macOS host or CI before relying on the stated cross-platform behavior. Relevant changed code:core/libs/prx/libkernel/Socket/src/Udp.cpp:3091andcore/libs/prx/libkernel/Socket/src/Udp.cpp:3284.
Sources
core/libs/prx/libkernel/Socket/src/Udp.cpp: pipe readiness, queue inspection, error detection, and poll result filtering.core/libs/tests/GuestPoll.cpp: added pipe, socket, low-water, datagram, and listener coverage.core/libs/tests/GuestNetKernelForwards.cpp: added guest socket and libSceNet coverage.docs/dev/debt/changes/feat-libkernel-poll-inignoreeof.mdanddocs/dev/debt/changes/fix-libkernel-select-poll-reuse.md: documented host differences and updated debt entry.
Not verified
- Tests and builds were not run in this review. The author reports Windows 11 tests and Linux syntax checks; those results were not independently verified.
- macOS-specific runtime behavior was not verified.
- Read the prepared description, commits, manifest, full diff, and all added lines for the five changed files; inspected relevant head ranges in the implementation and test files. Did not read the complete contents of the changed source and test files.
To get this to a good state
Nothing is required. Optional: verify the macOS path on a macOS host or CI.
…as a stub always_stub_calls read every preprocessor combination of each function that might reach NotImplemented_nid_no_patch before checking whether all of them call a stub. A helper that calls it only behind a condition, with more than 256 combinations, aborted the whole audit, although its first combination already shows it is not an always-stub helper. Since boykopovar#27260 libkernel's PollDescriptors is such a helper, so import_audit.py and audit_dump.py stop for every title. A combination with no call to a function that might reach a stub can never be satisfied, so reading stops there and the helper is left out, as the full read would have decided. Every body is still parsed first, so an unmatched #if in a later overload still fails the audit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
pollthrewNotImplementedforPOLLINIGNEOF(0x2000) on guest sockets, libSceNet sockets and pipes. FreeBSD 11.4'ssopoll_genericandpipe_pollskip their end-of-file block when the bit is set, andpollnow does the same:POLLHUPis never reported, and a hung-up descriptor reportsPOLLOUT.POLLIN/POLLRDNORMfollowsoreadabledata. A stream needs itsSO_RCVLOWATbytes queued, a datagram socket a queued datagram (an empty one counts), and a listener a pending connection. A pending socket error keeps the socket readable even after the guest's ownSHUT_RD.revents. A wait that the host ends with only dropped readiness is resumed.macOS's
polldoes not report a socket error asPOLLERR, so there the error is found with a peeking non-blockingrecv, which leaves it pending.A new debt entry lists the host differences that remain. The clause listing
POLLINIGNEOFamong the inputspollthrows on is removed from the pendingfix-libkernel-select-poll-reuse.mdfragment, becausedebt_foldrefuses a second fragment that changes the same entry.Tested
Windows 11, MinGW-w64 GCC 16.2, Release:
guest_pollandguest_sce_net_kernel_forwardspass (2/2, run repeatedly). The new checks cover:SHUT_WR, after its ownSHUT_RD, and afterSHUT_RDWR;SO_RCVLOWAT;SOCK_SEQPACKETpair, outside macOS, which has no seqpacket socketpair.The guest-socket and libSceNet paths are both covered.
Udp.cppandGuestPoll.cpppass g++-fsyntax-onlyfor Linux in WSL, andUdp.cppalso passes with the macOS-only blocks forced on. The macOS path has not been run: there is no macOS host here, and CI runsguest_pollonly on Linux and Windows. Onmain, every call with the bit threw.The overlap check reports #22398 (random-device
poll, a different change) on the same line offix-libkernel-select-poll-reuse.md. Whichever merges second rebases that line.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