fix(libkernel): clear POLLOUT from a hung-up socket in poll on Linux #9512
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9512"
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 EagleBearerYS on 2026-10-21T23:56:24Z.
Title-less conformance fixes of this kind are merged now, for example #7365 and #8411.
What
FreeBSD 11.4's
pollscanclearsPOLLOUTwhenever a descriptor reportsPOLLHUP(sys_generic.cL1593-L1598: "POSIX requires POLLOUT to be never set simultaneously with POLLHUP"). libkernel'spolldoes that for pipes, but on Linux a stream socket whose peer has closed and whose own sending side is shut down reportsPOLLOUTnext toPOLLHUP, because Linux'spollsets both.Linux sets
POLLHUPon a socket only once both directions are shut, the same condition as FreeBSD'ssopoll_generic, sopollnow clearsPOLLOUTfrom any entry that reportsPOLLHUPon Linux. Windows keeps the flagsWSAPollreports; #9492 changes how they are read on Windows.The second commit adds a
poll on a stream socketentry todocs/dev/debt/libkernel.md.No title is claimed.
Overlap, merge order only: this PR goes after #7605, which rewrites the
pollentry ofdocs/dev/debt/libkernel.mdthat this PR's new entry follows; the code changes merge cleanly. #8483 has landed (093149c5bd), and this PR is merged with it (3373495360): #8483's Windows change and this PR's Linux one sit side by side inpoll, andguest_pollruns both tests.Tested
On GitHub's runners from my fork, on
mainata6dcea9279(run):PollsAHungUpSocketWithoutPolloutinguest_poll, on Linux: the client closes, the server reads the end of the stream and shuts its own sending side, and aPOLLIN | POLLOUTpoll of the server must report exactlyPOLLIN | POLLHUP.main'sUdp.cppguest_pollfails. With the change it passes 10 runs in a row.guest_pollpasses with and without the change.core/libs/prx/libcandcore/libs/prx/libkernelpasses: 115 and 197 on Linux, 142 and 207 on Windows.mainatab347d144d(1983ed955d, run): on Linuxguest_pollfails withmain'sUdp.cppand passes 10 runs in a row with the change; on Windows it passes both ways. The libc and libkernel suites pass on both (116 and 197 on Linux, 143 and 207 on Windows).tools/pr_overlap.pyandgit merge-treefind the same overlaps as before: #7605 in the debt file, #8483 inGuestPoll.cppand the debt file, and none with #9492.main8499ea52e5merged in, which includes #8483 (run). Both sides ofGuestPoll.cppare kept: #8483'sPollsAStreamWhosePeerClosedand this PR'sPollsAHungUpSocketWithoutPollout, each called frommain(), and both debt entries. The PR's diff otherwise loses only theshutdown_nid_postfixdeclaration, whichmainnow has. On Linuxguest_pollfails 3 of 3 withmain'sUdp.cppand passes 10 of 10 with the change; on Windows it passes both ways. The libc and libkernel suites pass on both runners. The libc and libkernel suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.tools/check_conventions.py --base origin/mainpasses.a6dcea9279.guest_pollpasses 3 of 3, and withUdp.cppat the merge base and the PR's tests kept, it aborts.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 MarcZX10 on 2026-10-22T00:09:00Z.
Review: CHANGES_REQUESTED
The Linux behavior change and regression scenario are narrowly targeted, but the live overlap scan requires follow-up before merge. It reports overlaps with #7605 and #8483; I compared the heads directly with
git merge-treeand confirmed both combinations currently conflict indocs/dev/debt/libkernel.md, while #8483 also conflicts incore/libs/tests/GuestPoll.cppat the adjacent test insertion point. The #8483 behavior is Windows-specific and this PR’s code change is Linux/macOS-only, so this appears composable, but the repository rule still requires agreeing on merge order and declaringDepends onaccordingly. Please coordinate with those PR authors, resolve the resulting doc/test hunks, and update the checklist fromDepends on: none. I found no code correctness blocker in the reviewed Linux path. The PR reports focused Linux and Windows test results and current eligibility/intake/convention/label/report checks pass; I did not run tests locally.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T00:41:10Z.
Thanks, @MarcZX10. This PR now goes after #7605: Depends on lists it, and I've left a note there. #8483 is the duplicate of #9492, which is being settled with its author and the maintainers. This PR merges cleanly with #9492 (
git merge-treeof the two heads), and if #8483 is the one that goes in, this PR goes after it and resolves theGuestPoll.cppand debt-file hunks on rebase. The Overlap line in the description now gives the order.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:17:44Z.
Review: APPROVED
Re-reviewed the current Linux-specific change and its updated overlap note. The code clears
POLLOUTonly when the returned events includePOLLHUP, matching the cited FreeBSD poll rule; the PR clearly records that Windows retains WSAPoll behavior and that #8483 is mutually exclusive with #9492. The author reports Linux regressions and registered libc/libkernel suites, and current hosted checks are green. I did not run a local build. The previous order/coordination finding is resolved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:06:00Z.
Review: APPROVED
Rechecked the current head and the author’s overlap update. #7605 is now an explicit dependency; the #8483/#9492 mutually exclusive Windows change and alternate rebase order are documented. The Linux code clears
POLLOUTonly when a stream socket reportsPOLLHUP, matching the cited FreeBSDpollscanrule; the regression is Linux-focused and reports 10 consecutive passes, with broader libc/libkernel suites reported on Linux and Windows. Current eligibility, conventions, intake, labels and report checks pass. Product jobs are skipped. I did not run local tests.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-22T03:15:05Z.
Linux data point for
38e4c5e36c: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal), GCC 13.3.0, Release,BUILD_TESTING=ON, PR head alone (not merged ontomain; its merge-base isa6dcea927).ctest -R '^guest_poll$'passes 3 of 3.libkernel/Socket/src/Udp.cpprestored to the merge-base (the PR's tests kept): fails (Subprocess aborted).Not tested: macOS, Windows, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T03:20:42Z.
@xXPBSXx thanks for the Linux run, both red and green. It's in Tested now.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:20:52Z.
Review: DISMISSED
The Linux poll behavior and reported red/green regression remain consistent with the earlier review; the overlap note now declares #7605 and documents the alternative order with #8483/#9492. One repository requirement remains: the branch and reported tests are based on main
a6dcea9279, while current upstream main isc61d20f548. Please update the branch and rerun the focused poll test, conventions, and overlap check on the current base. The author-reported WSL results are not a rerun on the updated head; I did not run tests locally.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T05:03:54Z.
Thanks, @MarcZX10. The branch now has
mainatab347d144dmerged in (1983ed955d), and the PR's own diff is unchanged. On GitHub's runners (run)guest_pollfails on Linux withmain'sUdp.cppand passes 10 runs in a row with the change, and the libc and libkernel suites pass on both runners. Conventions pass, and the overlap check finds the same three PRs the description lists. Tested now says so.