feat(libkernel): poll on file descriptors and Windows pipe read ends #3649
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3649"
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 pushkarreddyy on 2026-10-11T14:44:32Z.
What
libkernel'spoll()previously threw for any descriptor below the socket range (0x10000000) withpoll: descriptor X is not a socket.This PR carries @screamm's fix from
screamm:feat/libkernel-poll-files(commitsc50ac7856ande8d123804, authorship preserved) rebased cleanly onto currentmain:POLLIN,POLLRDNORM, andPOLLOUTimmediately (following FreeBSD 11vop_stdpollandpoll_no_poll).POLLNVAL;POLLHUPclearsPOLLOUT(pollscan).poll.pipe()records descriptor ends (File/src/PipeEnd.cpp, tracked acrossdup,dup2,close,sceKernelClose); read ends answer viaPeekNamedPipe(POLLIN/POLLRDNORMwith buffered bytes, andPOLLIN|POLLRDNORM|POLLHUPonERROR_BROKEN_PIPE).Fixes #3521.
Tested
[TV] menu ready display=3840x2160) and runs past 60 s.what(): poll: descriptor 6 is not a socket (#3521)).guest_pollcovers filePOLLIN|POLLOUT, file + idle UDP socket returning 1 immediately, closed filePOLLNVAL, >1024 descriptors throwing, empty pipe read end, pipe read end ready after write,POLLHUPafter writer close, and write-end cases.python tools/check_conventions.py --base origin/main(0 comments in source).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T14:59:55Z.
Cross-linking for the review: this implements the fix tracked in #3521, which has an independent Linux verification on that issue — full suite 832/832 (CachyOS, kernel 7.2.9, GCC 16.2.1, including every Vulkan test on AMD RX 9070 XT / RADV), conventions check clean, rebased onto current
mainat the time. The Windows pipe read-end paths of this change are the part that could not be exercised there, so the report's Windows-side coverage complements it.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T15:24:45Z.
Windows validation of
e8d12380merged ontomaina11c8f7f(Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,BUILD_TESTING=ON, full build includinglibs): the poll test passes 3/3 with--repeat until-fail:3;ctest -j8 -E "^agc_driver_|^video_out_flip"531/536, the failures being the knownwindows_exceptions(#3411, fixed by #3415),guest_kernel_sys(#3510),guest_filesystem(#3518) and the load flakesagc_driver(#3171) andguest_ampr_markers(#3371). Same result as the original branch in #3521. Thanks for carrying it.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T15:55:17Z.
Calling on @adriadam10 for review when convenient:
Both platform verifications are complete for this carry of #3521:
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T17:19:07Z.
Cross-reference: #3644 implements the same fix (poll on pipe descriptors, tracked in #3521).
CONTRIBUTING.md asks authors to "check that no open pull request already implements the same functions" before starting — both PRs are open, so flagging for the maintainers.
The limitation this creates: only one of the two can be merged; the other gets closed as duplicate, and both currently cost review time in a 340+ queue.
Evidence to help the choice (independent pre-review, Linux — CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON):main;If it helps, either author can rebase onto the other or close their own; the choice is the maintainers'.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T20:09:00Z.
Verified this PR on both OSes with a title that needs it: ProsperoTV (PPSA99003, catalog 01.000.060).
Without this PR, but with
openatfrom #3968 so the title loads, it opens its TV menu and then aborts inpollright after opening/dev/crypto:poll: descriptor 6 is not a socketWith this PR stacked on #3968 (local merge of c50ac785/e8d12380, clean):
Vulkan device ready, thenDisplayWindowthrows because the runner has no display.last provoking vertex with explicit per-vertex flat interpolation is unsupported(#3581).guest_pollandguest_kernel_syspass 5/5 (--repeat until-fail:5) on Windows, with 0 warnings.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T00:36:34Z.
Heads-up from a Windows validation attempt:
e8d12380no longer merges ontomain(bab7b328/bca7a29d). The only conflict isdocs/dev/TechnicalDebt.md: #3592 (d694aac7) added a "Socket error numbers" bullet right after thepollbullet this PR rewrites; the code files merge cleanly, and the obvious resolution is to keep this PR'spollbullet followed bymain's new bullet. #3644 has the same conflict. It now blocks more titles: with #3494 applied, PSXS5 (PPSA97510) also stops atwhat(): poll: descriptor 6 is not a socket, in addition to ProsperoTV (PPSA99003) and ProsperoRadio (PPSA99001) from the third catalog run.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T02:06:35Z.
Hi @screamm and @adriadam10,
Thank you for the heads-up and validation on Windows!
The requested rebase onto latest origin/main (
d371ed307) is now complete on commit 5bf212852:Ready for review and merge. Thank you!
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T06:23:17Z.
Heads-up from a Windows validation attempt on the rebased head:
5dbe3637(base6253883d) no longer merges ontomain2ccbd376. The only conflict isStdio.cppinclose_nid_postfix, with #3923 (merged as5fe4bebe): this PR hasFile::ForgetPipeEnd(d); return _close(d);wheremainnow hasreturn WithoutParameterHandler([d] { return ::_close(d); });. The resolution is to keepFile::ForgetPipeEnd(d);followed bymain'sWithoutParameterHandlerreturn.Udp.cppandTechnicalDebt.mdmerge cleanly. I'll rerun the Windows build,guest_poll3/3, the suite and PSXS5/ProsperoTV/ProsperoRadio once it is rebased.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T06:36:47Z.
Hi @screamm,
Thank you for the heads-up!
The rebase onto latest \origin/main\ (\
2ccbd376f) is complete on commit \16820c49:Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T11:48:50Z.
Hi @adriadam10 and @screamm,
Cleanly rebased onto latest origin/main (fa198407) on commit 1c369185d:
Ready for final review and merge! Thank you!
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T11:51:49Z.
Heads-up:
b16820c4conflicts again with currentmain3d8ffeb2, this time with #3840 (5f3b94cb, fcntl on non-socket descriptors):libkernel/CMakeLists.txt(this PR addsFile/src/DescriptorPoll.cpp,mainaddsFile/src/DescriptorControl.cppon the same line; both stay) andStdio.cppinpipe_nid_postfix(this PR'sFile::RememberPipeEnd(native[0|1], ...)next tomain'sFile::RememberDescriptor(native[0|1], 0)) anddup2_nid_postfix(this PR'sFindPipeEnd/RememberPipeEnd/ForgetPipeEndnext tomain'sFile::ShareDescriptor(from, to)); both sides are needed in both places. Since both branches are mine, I'm preparing the resolved rebase with a Windows build,guest_polland the four title runs (PSXS5, SwanStation, ProsperoTV, ProsperoRadio) and will post the commits here for @pushkarreddyy to take.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T12:02:51Z.
Hi @screamm,
Thank you very much for the heads-up and for detailing the resolution points with #3840!
The rebase onto latest
origin/main(ffa198407) is already complete and pushed on HEAD (4b1b35864), resolving the conflict with #3840 exactly as you described:CMakeLists.txt: Retained bothDescriptorControl.cppandDescriptorPoll.cpp.Stdio.cpp(pipe_nid_postfix): KeptFile::RememberDescriptor(native[0|1], 0)alongsideFile::RememberPipeEnd.Stdio.cpp(close_nid_postfix): KeptFile::ForgetPipeEnd(d)alongsideWithoutParameterHandler([d] { return ::_close(d); }).Stdio.cpp(dup2_nid_postfix): KeptFile::ShareDescriptor(from, to)alongside pipe-end tracking (FindPipeEnd/RememberPipeEnd/ForgetPipeEnd).Authorship on both commits (
06ddffb29and4b1b35864) is preserved (David <[email protected]>), andtools/check_conventions.py --base origin/mainpasses cleanly with zero comments.The branch is ready for your Windows validation run with
guest_polland the four titles (PSXS5, SwanStation, ProsperoTV, ProsperoRadio). Thank you!Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T12:26:49Z.
Windows validation of the rebased head
1c369185onmainffa19840(my own rebase of the same two commits has identical file contents, so I validated that; Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Release,BUILD_TESTING=ON, full build includinglibs):guest_poll,guest_kernel_fcntl,guest_dup,guest_socket_pair,guest_terminal3/3;ctest -j8 -E "^agc_driver_|^video_out_flip"604/606, the two beingaudio_out2_timing(load-sensitive, #4347) andguest_sce_net(timer-resolution check inCheckEmptyEpoll, unrelated topoll), both passing serially (40/40); conventions andgit diff --checkpass. The pipe-end table and #3840's descriptor table stay in step acrossclose,sceKernelClose,dup,dup2andF_DUPFD.Titles relinked against this build (run 4 runtime, libs and relinker from this build), all four get past the
poll-on-a-pipe stop:main)what(): poll: descriptor 6 is not a socketat 42 swhat(): poll: POLLPRI is not supported by WSAPollon guest socket0x10000002with events `POLLPRIpoll: descriptor 7 is not a socketPOLLPRIthrow on sockets0x10000003/0x10000002(threads gamedb, update) at 12.7 swhat(): poll: descriptor 3 is not a socket{3, POLLIN},{5, POLLIN}+{3, POLLIN},{0x10000001, POLLOUT}+{3, POLLIN}pass, then `{0x10000001, POLLPRIwhat(): poll: descriptor 3 is not a socketat 44 swhat(): fcntl: record locks are not implemented on Windows, command=12, fd=3at 33.7 s (#3840's recorded Windows limit)So the PR removes the current stop of all four titles; the next stops are the existing Windows limits for
POLLPRIon a guest socket (a non-blockingconnectcheck, three titles) andF_SETLKrecord locks (ProsperoRadio), which I'm taking up next. One request for the rebase: the two commits still carry the placeholder authorDavid <[email protected]>from the original branch;git rebase --exec 'git commit --amend --author="screamm <[email protected]>" --no-edit'over the two would attribute them correctly.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T13:37:09Z.
Calling on @adriadam10 and @MarcZX100 for review clearance / merge:
This carried branch for #3521 is fully rebased and verified on both platforms:
polltoVulkan device readyand 5/5 unit tests; verified by @screamm with 3/3 repeat passes and 531/536 tests. Resolves PSXS5 (PPSA97510) 31-second stop from #3494 (poll: descriptor 6 is not a socket).origin/main(ddc713fbc), resolving descriptor control & pipe-end tracking alongside merged #3840. Original authorship (David <[email protected]>) preserved.mergeable: true, 0 comments in C++, all CI checks green.Ready for review clearance and merge! Thank you!
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-12T15:30:11Z.
Update after #4030 (provoking-vertex fix) merged: on plain
maind592d54e, Windows 11 (WinLibs GCC 15.2, Release), ProsperoTV (PPSA99003) no longer hits the AGC provoking-vertex throw. Its only stop now is the one this PR fixes:Earlier I ran this branch stacked with openat (#3968, since merged), and ProsperoTV went past
polltoVulkan device readyon both systems, so on Windows this PR is now all that stands between ProsperoTV and rendering. Stremio Plus and PShare, which were also blocked by the provoking-vertex throw, now render until the timeout onmain.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T16:28:02Z.
@screamm @babyhuey Rebased cleanly on latest origin/main (
2a5eca11c):Ready for review clearance and merge!
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T18:12:07Z.
Calling on @oneandonlydean, @adriadam10, @MarcZX100, @babyhuey, and @screamm for final merge review:
This PR has been ready, fully rebased on latest
origin/main(2a5eca11c), and passing all CI checks 100% green. It unblocks major progress across multiple titles:PPSA99003): As confirmed by @babyhuey on Windows 11, following the merge of #4030, ProsperoTV no longer hits the provoking-vertex throw and is solely halted on this PR (poll: descriptor 4 is not a socket). Merging this PR is all that stands between ProsperoTV and full rendering!PPSA97510, SwanStationPPSA98510, ProsperoTVPPSA99003, ProsperoRadioPPSA99001) advance past thepollstop, with 604/606 tests passing.2a5eca11c, 0 merge conflicts, authorship attributed toscreamm <[email protected]>, 0 comments in C++, all CI checks passing green.Ready for review clearance and merge! Thank you everyone for your assistance and testing!
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T20:41:55Z.
One review dependency changed since the earlier duplicate check: #4391 is now the low-descriptor socket change, and it edits
Udp.cppwhere this PR also adds mixed socket/file polling. Before I can clear this carry, please coordinate the merge order or stack one branch on the other and validate the combined result. The existing #3644 duplicate also still needs a maintainer choice; both are currently presented as equivalent fixes for #3521.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:57:58Z.
#3644 is merged for #3521, so this one doesn't go in as it is. The titles here poll a pipe next to their sockets. #3644 puts that pipe into the same host
pollas the sockets on Linux and checks it every 1 ms on Windows; this one checks it between 100 ms socket waits on both hosts (HostPollSliceMilliseconds,Udp.cpp), and on Windows throws forPOLLOUTon a write end. It also hands back the host's answer for descriptors it doesn't know: akqueuedescriptor is/dev/nullon the host, so on Linuxpollreports it readable at once.What is left here is regular files, directories and shared memory, and the 1024 limit. Which title polls one of those? With the ID and the log line, open that part as its own PR on main; otherwise I'll close this.
@screamm could you run the four titles on main now? Only PPSA99003 and PPSA99288 had a run on #3644.
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T01:52:11Z.
@oneandonlydean @MarcZX100 Understood — all four catalog titles (
PPSA97510,PPSA99288,PPSA99004,PPSA99003) as well asPPSA99902in #3521 were polling their wakeup pipe (Curl_wait_ms/ event pipe) alongside sockets, which is now covered onmainby #3644 (4430780bd, verified by @babyhuey in #4525).No title on
maincurrently stops onpoll: descriptor <N> is neither a socket nor a pipefor a regular file, directory, or shared memory descriptor. Closing this PR in favor of #3644; if a title reachespollon a regular file or directory descriptor onmain, we will open a dedicated PR with its runtime log line.Pull request closed