fix(libkernel): poll pipe descriptors #3644
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3644"
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 DariusHQ on 2026-10-11T14:41:17Z.
What
Fixes #3584.
pollthrewdescriptor N is not a socketfor any descriptor below the guest socket range. ProsperoTV (PPSA99003) polls the read end of apipenext to its sockets and stopped right after its menu opened, onmaina11c8f7f7, Windows, catalog build (eboot.binandsce_module/libc.prxunwrapped as #2605 requires):With this branch, run the same way, the menu finishes (
[TV] menu ready display=3840x2160 ... in 1259 ms), its catalog request goes out, and it stops later at the AGC stop that #3581 tracks for five other titles:Pipe readiness follows FreeBSD 11's
pipe_poll:POLLIN/POLLRDNORMwhen data is buffered;POLLIN/POLLRDNORMandPOLLHUP, and the write end reportsPOLLOUTandPOLLHUP;POLLOUTwhen at leastPIPE_BUF(512) bytes are free;On Linux the pipe goes to the host
pollwith the sockets. Linux reportsPOLLERRfor a write end whose reader is gone; that becomesPOLLOUT | POLLHUP, as on FreeBSD. On Windows a CRT pipe can't be waited on withWSAPoll, so while a pipe is in the set,pollreads its buffered and free bytes and the pipe state withNtQueryInformationFile(FilePipeLocalInformation, andFileAccessInformationfor the end's access) and waits on the sockets in 1 ms slices until something is ready or the timeout passes. Sets without a pipe wait exactly as before.A closed descriptor below the socket range now reports
POLLNVAL, as FreeBSD does and as closed sockets already did. Other descriptors there (regular files, terminals) still throw. TechnicalDebt'spollentry is updated.selecton non-socket descriptors is a separate path (Socket.cpp, #3462) and is unchanged.Tested
Windows 11 (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build with
BUILD_TESTING=ONona11c8f7f7:ctest832/836 passed. The four failures fail the same way onmainhere:windows_exceptions(#3411);guest_kernel_sys:symlinkthrowsFunction not implementedon Windows, which #3510 addresses;guest_filesystem: restoring the directory time fails on Windows, which #3518 addresses;agc_driver_emulated_color_compare: the GPU here cannot sample the sRGB image it uses.guest_pollnow also checks, on apipe:POLLIN | POLLRDNORMasked;POLLIN | POLLRDNORM | POLLHUPwith data left and once drained;POLLOUT | POLLHUPon the write end;POLLNVAL.It passed 20/20 runs. Mutation check, caught:
POLLHUP;POLLNVAL;One survived: writable at any free byte instead of 512. The test fills the pipe 256 bytes at a time, so it can't tell the two apart.
Not run on Linux (no Linux host here). The Linux path is the existing host
pollwith pipes added to the set, plus thePOLLERRmapping.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-11T15:19:46Z.
Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON.tools/check_conventions.py --base origin/mainpasses.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T21:09:16Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/tests/GuestPoll.cppL0-1, L5, L21, L28-29docs/dev/debt/libkernel.mdL143Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T00:08:54Z.
Tested on Linux (CachyOS, RTX 2070, NVIDIA 615.71.09) with Nuvio Max'd (PPSA99288), built from
mainate6ecece94with this PR merged on top.Without this PR the title aborts about 14 s after start with
poll: descriptor 64 is not a socket(frompoll_nid_postfix, called on a worker thread). With it, the title runs and renders its UI at 59.94 FPS; the next stop is a network failure unrelated topoll.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-13T00:15:24Z.
Independent Windows validation of this implementation, cleanly carried onto pinned main
e6ecece94e5b8f241dc86c14d326eed2347044fbwith original authorship preserved: tested fork head45e3f7b56, derived from upstream head7250306b7. This is an adapted current-main validation, not a retest of the older base.guest_poll,guest_udp,guest_tcp,guest_socket_pair,guest_socket_read_write,guest_dup.Udp.cppreproducespoll: descriptor ... is not a socket; restoring the implementation passes. Source is restored/clean.Windows11 Enterprise26200, WinLibs GCC15.2.0r7 /Ninja Release/testing ON, bundled dependencies; RTX5080 driver610.62, AnyPS5 shader cache disabled. Driver-cache coldness and Linux execution are unverified in this campaign.
Additional title needing the pipe path: Sonic Unleashed Recompiled, PPSA99902 /01.003.000. Our conditional #4822 libc-only replay stops on the original non-socket guard. A scalar observer confirms pipe read ends requesting POLLIN with timeout=-1 and count1; #3521's existing comment has the exact pair/event records. Kernel-only conditional title comparison completed: on the fixed-libc #4822 profile, the original libkernel aborts on non-socket poll after9.981s. Replacing only libkernel.prx with this implementation removes that observed abort. A captured frame was inspected and shows the SEGA startup logo; the process continues until 789.240s, then exits0xC0000409 without timeout at the existing private integration guard:
The other123 library hashes, including the fixed libc, and executable hash are unchanged. Native selected groups ×5 and conventions/registration also pass on the experimental adaptation. Original executable/bundled libc, baseline runtime, converted guest and user data are restored/hash-verified; tracked source is clean. The four scheduled input pulses and two additional3000ms pulses are recorded separately; consumption and reliable menu navigation remain unverified. Early frame captures establish startup rendering, not gameplay or unique-frame FPS. The MSAA guard is local to the preserved experimental stack, already investigated in #2132/#419; this replay supplies no new actual guest-write/coherence verdict and does not justify a new main-defect issue or relaxing the guard. Validated experimental fork headfac106b2b. Bring-up: #4443.
This validation does not select between the overlapping #3644/#3649 submissions or validate their combination with the low-socket-descriptor change #4391. AI-assisted: Codex; author responsible.
Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T00:16:34Z.
guest_pollaborts on Linux (Ubuntu 24.04 container,mainate6ecece94with only this PR applied), at the check after draining 1 KiB from the filled pipe:Linux merges the 256-byte writes into 4 KiB pipe pages and reports
POLLOUTonly once a whole page slot is free, so reading 1 KiB leaves the pipe full and the hostpollreports noPOLLOUT, as the debt entry allows ("writable … when the host kernel says so on Linux"). Reading the whole pipe back before that check, or at least 4096 bytes, should hold on both hosts. The pipe read-end path itself works with Nuvio Max'd as reported above.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:40:50Z.
Pushed
64ca6e33on top of your commit, so this can be built:guest_pollaborted on Linux atGuestPoll.cpp:91: Linux givesPOLLOUTback only when a whole 4 KiB page is free, and the test read 1 KiB. It now drains the pipe before that check, which holds on any host (the Windows pipe is 4096 bytes, so a fixed 4 KiB read would not).POLLHUPalone, on both hosts. FreeBSD'spollscanclearsPOLLOUTwhenPOLLHUPis set (sys_generic.c:1597).POLLOUTon a read end throws. FreeBSD opens both endsFREAD | FWRITE(sys_pipe.c:422) and reports it writable, which a one-way host pipe can't back, and no title asks for it.The debt entry is updated to match. On Linux, merged with main: full build, ctest 995/995 (7 skipped),
guest_poll10/10, conventions check passes. The Windows path is not run here; the full build covers it.