libkernel: poll throws for non-socket descriptors, first stop of ProsperoTV on main; fix branch ready (files and Windows pipe read ends) #3521

Closed
opened 2026-10-11 12:13:00 +00:00 by screamm · 4 comments
screamm commented 2026-10-11 12:13:00 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T12:13:00Z.


libkernel's poll throws for any descriptor that is not a libSceNet socket. On current main 0f863c10 that is the first stop of PPSA99003 (ProsperoTV; the line is in the title's own download0/.../app.log):

what():  poll: descriptor 3 is not a socket

Descriptor 3 there is a pipe read end.

Fix branch ready: screamm:feat/libkernel-poll-files (two commits on main 0f863c10: 632eb162 feat(libkernel): poll on file descriptors, 839a9f0e feat(libkernel): poll Windows pipe read ends). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are. It shares the File/src/DescriptorPoll.cpp helper with the select branch of #2811 (not merged), extended here, so the two will need one rebase whichever lands first.

  • Commit 1, after FreeBSD 11.4 sys_generic.c (sys_poll, kern_poll, pollscan, poll_no_poll), vfs_default.c and uipc_shm.c (8c639945): descriptors below the socket range go through the helper; regular files, directories and anonymous shm report the requested POLLIN/POLLRDNORM/POLLOUT at once and never the band events; on Linux pipes and character devices use host poll; closed descriptors get POLLNVAL; POLLHUP clears POLLOUT; mixed arrays poll the sockets without waiting once a host descriptor is ready, otherwise in 100 ms slices within the one timeout. Throws: more than 1024 descriptors (the console's maxfilesperproc is unknown), Windows consoles and unknown handles, the random device, the existing unsupported bits.
  • Commit 2: pipe now records each end on Windows (File/src/PipeEnd.cpp, copied by dup/dup2, dropped by close); a read end answers through PeekNamedPipe (POLLIN/POLLRDNORM with bytes available; POLLIN|POLLHUP on ERROR_BROKEN_PIPE, as FreeBSD's pipe_poll reports end of file), a write end reports nothing for read events and POLLOUT on it throws, since the host does not report free space; pipes not created by pipe throw. The two FreeBSD differences (a writer closing with buffered bytes shows no POLLHUP until drained; a write end whose reader closed reports nothing) are in TechnicalDebt.
  • guest_poll gains a file with POLLIN|POLLOUT, a file plus an idle UDP socket returning 1 at once, a UDP-only 200 ms timeout, a closed file POLLNVAL, 1025 descriptors throwing, an empty pipe read end not ready and ready after a write, POLLHUP after the writer closes, and the write-end cases.

Title run: with the rebuilt libkernel.prx PPSA99003 gets past the call, logs [TV] menu ready display=3840x2160, and keeps running until killed at 60 s; its next stop is the known graphics one, AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: guest_poll, guest_udp, guest_tcp, guest_socket_pair, guest_socket_read_write, guest_dup 3/3; ctest -j8 -E "^agc_driver_|^video_out_flip" 533/534, the one failure being windows_exceptions (#3411); with main's Udp.cpp the extended guest_poll fails; tools/check_conventions.py --base main and git diff --check pass. Linux only syntax-checked.

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5800938926 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3521). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T12:13:00Z. --- libkernel's `poll` throws for any descriptor that is not a libSceNet socket. On current `main` `0f863c10` that is the first stop of PPSA99003 (ProsperoTV; the line is in the title's own `download0/.../app.log`): ``` what(): poll: descriptor 3 is not a socket ``` Descriptor 3 there is a pipe read end. **Fix branch ready:** [`screamm:feat/libkernel-poll-files`](https://github.com/screamm/AnyPS5/tree/feat/libkernel-poll-files) (two commits on `main` `0f863c10`: `632eb162` `feat(libkernel): poll on file descriptors`, `839a9f0e` `feat(libkernel): poll Windows pipe read ends`). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are. It shares the `File/src/DescriptorPoll.cpp` helper with the `select` branch of #2811 (not merged), extended here, so the two will need one rebase whichever lands first. - Commit 1, after FreeBSD 11.4 `sys_generic.c` (`sys_poll`, `kern_poll`, `pollscan`, `poll_no_poll`), `vfs_default.c` and `uipc_shm.c` (`8c639945`): descriptors below the socket range go through the helper; regular files, directories and anonymous shm report the requested `POLLIN`/`POLLRDNORM`/`POLLOUT` at once and never the band events; on Linux pipes and character devices use host `poll`; closed descriptors get `POLLNVAL`; `POLLHUP` clears `POLLOUT`; mixed arrays poll the sockets without waiting once a host descriptor is ready, otherwise in 100 ms slices within the one timeout. Throws: more than 1024 descriptors (the console's `maxfilesperproc` is unknown), Windows consoles and unknown handles, the random device, the existing unsupported bits. - Commit 2: `pipe` now records each end on Windows (`File/src/PipeEnd.cpp`, copied by `dup`/`dup2`, dropped by `close`); a read end answers through `PeekNamedPipe` (`POLLIN`/`POLLRDNORM` with bytes available; `POLLIN|POLLHUP` on `ERROR_BROKEN_PIPE`, as FreeBSD's `pipe_poll` reports end of file), a write end reports nothing for read events and `POLLOUT` on it throws, since the host does not report free space; pipes not created by `pipe` throw. The two FreeBSD differences (a writer closing with buffered bytes shows no `POLLHUP` until drained; a write end whose reader closed reports nothing) are in TechnicalDebt. - `guest_poll` gains a file with `POLLIN|POLLOUT`, a file plus an idle UDP socket returning 1 at once, a UDP-only 200 ms timeout, a closed file `POLLNVAL`, 1025 descriptors throwing, an empty pipe read end not ready and ready after a write, `POLLHUP` after the writer closes, and the write-end cases. **Title run:** with the rebuilt `libkernel.prx` PPSA99003 gets past the call, logs `[TV] menu ready display=3840x2160`, and keeps running until killed at 60 s; its next stop is the known graphics one, `AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported`. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: `guest_poll`, `guest_udp`, `guest_tcp`, `guest_socket_pair`, `guest_socket_read_write`, `guest_dup` 3/3; `ctest -j8 -E "^agc_driver_|^video_out_flip"` 533/534, the one failure being `windows_exceptions` (#3411); with `main`'s `Udp.cpp` the extended `guest_poll` fails; `tools/check_conventions.py --base main` and `git diff --check` pass. Linux only syntax-checked. Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
blawesom commented 2026-10-11 13:08:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T13:08:54Z.


Independent verification on Linux: CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Rebased 8c639945 onto current main: applies cleanly, no conflicts.
  • tools/check_conventions.py --base origin/main and git diff --check pass.
  • The poll/filesystem tests pass, including the new Windows pipe read-end cases (the POSIX paths exercised here).
  • Full suite: 832/832 (AMD RX 9070 XT / RADV).

The rebased branch is available at blawesom:verify/3521 for anyone carrying — the commit is otherwise unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109356513 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3521#issuecomment-6109356513). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T13:08:54Z. --- Independent verification on **Linux**: CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Rebased `8c639945` onto current `main`: applies cleanly, no conflicts. - `tools/check_conventions.py --base origin/main` and `git diff --check` pass. - The poll/filesystem tests pass, including the new Windows pipe read-end cases (the POSIX paths exercised here). - Full suite: **832/832** (AMD RX 9070 XT / RADV). The rebased branch is available at [`blawesom:verify/3521`](https://github.com/blawesom/AnyPS5/tree/verify/3521) for anyone carrying — the commit is otherwise unchanged.
pushkarreddyy commented 2026-10-11 14:45:50 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-11T14:45:50Z.


Hi @screamm! I have carried your branch feat/libkernel-poll-files into #3649 (feat(libkernel): poll on file descriptors and Windows pipe read ends) rebased cleanly on current main (a11c8f7), with your commits (c50ac7856 and e8d123804) and authorship fully preserved!

All PR intake, eligibility, and convention checks have passed cleanly. This also resolves the runtime abort observed on PSXS5 (PPSA97510 2.2.0) at the 31-second mark (what(): poll: descriptor 6 is not a socket (#3521)) verified by @orishamir in #3494. Thank you for the great work on this implementation!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110209955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3521#issuecomment-6110209955). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-11T14:45:50Z. --- Hi @screamm! I have carried your branch `feat/libkernel-poll-files` into **#3649** (`feat(libkernel): poll on file descriptors and Windows pipe read ends`) rebased cleanly on current `main` (`a11c8f7`), with your commits (`c50ac7856` and `e8d123804`) and authorship fully preserved! All PR intake, eligibility, and convention checks have passed cleanly. This also resolves the runtime abort observed on *PSXS5* (`PPSA97510` 2.2.0) at the 31-second mark (`what(): poll: descriptor 6 is not a socket (#3521)`) verified by @orishamir in #3494. Thank you for the great work on this implementation!
Amoenus commented 2026-10-12 23:48:50 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-12T23:48:50Z.


Additional title evidence for the existing non-socket poll guard: Sonic Unleashed Recompiled (PPSA99902 /01.003.000), Windows11 Enterprise26200, WinLibs GCC15.2r7 /Release, RTX5080. After a controlled libc-only #4822 comparison, the conditional title run aborts at:

what(): poll: descriptor 3 is not a socket
what(): poll: descriptor 5 is not a socket

The current integration and current main e6ecece94 have the same Socket/src/Udp.cpp Git blob 8f1fd2bfd7ca6135143699d03cd305c72e8b0760; the refusal is unchanged. The fixed replay exits0xC0000409 after9.981s, no timeout/frames. A subsequent scalar observer confirms pipe read ends, with descriptor numbers shifted by instrumentation:

[pipe-validation] read_fd=4 write_fd=5
[poll-validation] index=0 count=1 timeout=-1 fd=4 events=0x0001 nativeValid=1 fileType=3
[pipe-validation] read_fd=5 write_fd=6
[poll-validation] index=0 count=1 timeout=-1 fd=5 events=0x0001 nativeValid=1 fileType=3

The creation pairs identify the read end from _pipe slot0 (Microsoft contract); GetFileType=3 and valid CRT handles corroborate the pipe class. Both calls request POLLIN (0x1) and an infinite wait (-1), count1. The observer run stops after9.827s, with the same guard and restored assets/runtime/user data. It is separate from the uninstrumented descriptor3/5 run; no fixed descriptor number is assumed. Production source is restored exactly and its ordinary libraries rebuilt. The clean current-main carry of #3644 now passes six native groups ×20 and full NVIDIA1011/0/8 of1019. Its kernel-only title comparison removes the poll abort, renders the SEGA startup logo and runs to the existing private MSAA guard after789.240s, without timeout. Originals/runtime/user data are restored. The updated #3644 validation comment has the source/profile scope, commands and remaining limits. This validates the pipe implementation in the conditional stack; #3649 and the combination with #4391 remain untested here. This is a conditional profile with private prerequisites, not a whole-main title launch. Original executable/bundled libc, baseline runtime, converted guest and user data were restored/hash-verified. The fresh control, exact-source and one-library hash checks are in #4814 and the #4822 validation comment. I will update this comment with controlled fix validation; no duplicate issue/PR is being created for this guard. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134814409 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3521#issuecomment-6134814409). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-12T23:48:50Z. --- Additional title evidence for the existing non-socket poll guard: **Sonic Unleashed Recompiled (PPSA99902 /01.003.000), Windows11 Enterprise26200, WinLibs GCC15.2r7 /Release, RTX5080**. After a controlled libc-only #4822 comparison, the conditional title run aborts at: ```text what(): poll: descriptor 3 is not a socket what(): poll: descriptor 5 is not a socket ``` The current integration and current main `e6ecece94` have the same `Socket/src/Udp.cpp` Git blob `8f1fd2bfd7ca6135143699d03cd305c72e8b0760`; the refusal is unchanged. The fixed replay exits0xC0000409 after9.981s, no timeout/frames. A subsequent scalar observer confirms pipe read ends, with descriptor numbers shifted by instrumentation: ```text [pipe-validation] read_fd=4 write_fd=5 [poll-validation] index=0 count=1 timeout=-1 fd=4 events=0x0001 nativeValid=1 fileType=3 [pipe-validation] read_fd=5 write_fd=6 [poll-validation] index=0 count=1 timeout=-1 fd=5 events=0x0001 nativeValid=1 fileType=3 ``` The creation pairs identify the read end from `_pipe` slot0 ([Microsoft contract](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/pipe?view=msvc-170)); `GetFileType=3` and valid CRT handles corroborate the pipe class. Both calls request POLLIN (`0x1`) and an infinite wait (`-1`), count1. The observer run stops after9.827s, with the same guard and restored assets/runtime/user data. It is separate from the uninstrumented descriptor3/5 run; no fixed descriptor number is assumed. Production source is restored exactly and its ordinary libraries rebuilt. The clean current-main carry of #3644 now passes six native groups ×20 and full NVIDIA1011/0/8 of1019. Its kernel-only title comparison removes the poll abort, renders the SEGA startup logo and runs to the existing private MSAA guard after789.240s, without timeout. Originals/runtime/user data are restored. [The updated #3644 validation comment](https://github.com/boykopovar/AnyPS5/pull/3644#issuecomment-6135121778) has the source/profile scope, commands and remaining limits. This validates the pipe implementation in the conditional stack; #3649 and the combination with #4391 remain untested here. This is a conditional profile with private prerequisites, not a whole-main title launch. Original executable/bundled libc, baseline runtime, converted guest and user data were restored/hash-verified. The fresh control, exact-source and one-library hash checks are in [#4814](https://github.com/boykopovar/AnyPS5/issues/4814) and [the #4822 validation comment](https://github.com/boykopovar/AnyPS5/pull/4822#issuecomment-6134583756). I will update this comment with controlled fix validation; no duplicate issue/PR is being created for this guard. AI-assisted: Codex.
oneandonlydean commented 2026-10-13 02:07:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:07:03Z.


Closing: fixed by #3644, which polls pipe descriptors; that is the poll: descriptor 3 is not a socket stop of PPSA99003 and PPSA99902. poll on a regular file still throws (is neither a socket nor a pipe); #3649 is open for that, and POLLPRI is #4478.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6136596400 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3521#issuecomment-6136596400). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T02:07:03Z. --- Closing: fixed by #3644, which polls pipe descriptors; that is the `poll: descriptor 3 is not a socket` stop of PPSA99003 and PPSA99902. `poll` on a regular file still throws (`is neither a socket nor a pipe`); #3649 is open for that, and POLLPRI is #4478.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#3521
No description provided.