fix(libkernel): poll files, pipes and stdio descriptors #1832

Closed
TideOPL wants to merge 3 commits from upstream-pr/1832 into main
TideOPL commented 2026-10-08 20:49:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-08T20:49:27Z.


What

poll threw for every descriptor below GuestSockets::FirstDescriptor, so a title that polls a file, a pipe or stdio (alone or next to its sockets) stopped there. That TechnicalDebt entry had no open PR (#1706 does the same for select, Linux only).

  • Linux: a host descriptor goes into the same host poll call as the sockets, with the same flag mapping. Readiness, POLLHUP and POLLNVAL come from the host.
  • Windows: WSAPoll takes only sockets. A disk file (GetFileType = FILE_TYPE_DISK) or a directory descriptor is ready at once for the requested POLLIN, POLLOUT and POLLRDNORM. That is FreeBSD's default vnode poll answer (vop_nopoll/vop_stdpoll: events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)). A descriptor with no CRT handle reports POLLNVAL, with the CRT invalid-parameter handler suppressed as NativeClose does. Pipes and consoles still throw.
  • The request-building code shared by sockets and host descriptors is now one helper, AddPollRequest.

The TechnicalDebt entry is updated: Windows pipes and consoles still throw, and the vnode answer is not confirmed for the console's file systems.

Tested

  • Windows 11, MinGW-w64 GCC 15.2: guest_poll passes. The new cases fail on main (the export throws, exit 0xc0000409) and pass with the change.
  • Linux (Ubuntu 24.04 under WSL2, GCC 13.3): guest_poll passes, including the pipe cases
  • New cases in core/libs/tests/GuestPoll.cpp:
    • a disk file polled with POLLIN | POLLPRI | POLLOUT | POLLRDNORM next to an idle listening socket, with an infinite timeout: returns 1 at once, the file reports POLLIN | POLLOUT | POLLRDNORM and the socket reports nothing
    • the same descriptor after close: POLLNVAL
    • Linux only, a pipe: the write end is writable, the read end becomes readable after a write, and it reports POLLIN/POLLHUP after the writer closes
  • Full build and full ctest on both: Windows 479/479 pass; Linux 485 pass, with 24 AGC subgroup/GPU tests skipped because WSL2 has no suitable Vulkan device. guest_udp, guest_tcp and guest_sce_net, which link the same file, pass on both.
  • tools/check_conventions.py (with this description) and tools/check_test_registration.py pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792622856 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1832). Originally posted by [TideOPL](https://github.com/TideOPL) on 2026-10-08T20:49:27Z. --- ### What `poll` threw for every descriptor below `GuestSockets::FirstDescriptor`, so a title that polls a file, a pipe or stdio (alone or next to its sockets) stopped there. That TechnicalDebt entry had no open PR (#1706 does the same for `select`, Linux only). - **Linux**: a host descriptor goes into the same host `poll` call as the sockets, with the same flag mapping. Readiness, `POLLHUP` and `POLLNVAL` come from the host. - **Windows**: `WSAPoll` takes only sockets. A disk file (`GetFileType` = `FILE_TYPE_DISK`) or a directory descriptor is ready at once for the requested `POLLIN`, `POLLOUT` and `POLLRDNORM`. That is FreeBSD's default vnode poll answer (`vop_nopoll`/`vop_stdpoll`: `events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)`). A descriptor with no CRT handle reports `POLLNVAL`, with the CRT invalid-parameter handler suppressed as `NativeClose` does. Pipes and consoles still throw. - The request-building code shared by sockets and host descriptors is now one helper, `AddPollRequest`. The TechnicalDebt entry is updated: Windows pipes and consoles still throw, and the vnode answer is not confirmed for the console's file systems. ### Tested - Windows 11, MinGW-w64 GCC 15.2: `guest_poll` passes. The new cases fail on `main` (the export throws, exit 0xc0000409) and pass with the change. - Linux (Ubuntu 24.04 under WSL2, GCC 13.3): `guest_poll` passes, including the pipe cases - New cases in `core/libs/tests/GuestPoll.cpp`: - a disk file polled with `POLLIN | POLLPRI | POLLOUT | POLLRDNORM` next to an idle listening socket, with an infinite timeout: returns 1 at once, the file reports `POLLIN | POLLOUT | POLLRDNORM` and the socket reports nothing - the same descriptor after `close`: `POLLNVAL` - Linux only, a pipe: the write end is writable, the read end becomes readable after a write, and it reports `POLLIN`/`POLLHUP` after the writer closes - Full build and full `ctest` on both: Windows 479/479 pass; Linux 485 pass, with 24 AGC subgroup/GPU tests skipped because WSL2 has no suitable Vulkan device. `guest_udp`, `guest_tcp` and `guest_sce_net`, which link the same file, pass on both. - `tools/check_conventions.py` (with this description) and `tools/check_test_registration.py` pass. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
oneandonlydean commented 2026-10-09 09:22:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:35Z.


Which title polls a file, pipe or stdio descriptor on main? With the ID and the log line where it stops this can go in; otherwise I'll close it until one does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078125161 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1832#issuecomment-6078125161). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:35Z. --- Which title polls a file, pipe or stdio descriptor on main? With the ID and the log line where it stops this can go in; otherwise I'll close it until one does.
github-actions[bot] commented 2026-10-09 10:26:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T10:26:20Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#1857 docs/dev/TechnicalDebt.md L349
#2080 core/libs/prx/libkernel/Socket/src/Udp.cpp L15
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079050490 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1832#issuecomment-6079050490). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T10:26:20Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1857 | `docs/dev/TechnicalDebt.md` [L349](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/docs/dev/TechnicalDebt.md#L349) | | | | #2080 | `core/libs/prx/libkernel/Socket/src/Udp.cpp` [L15](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/libs/prx/libkernel/Socket/src/Udp.cpp#L15) | | |
reyani-dev commented 2026-10-11 13:48:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T13:48:53Z.


@TideOPL a title now stops here on main (a11c8f7f): ProsperoTV (PPSA99003), right after its menu opens, polling the read end of a pipe (descriptor 3) next to its sockets. Log line (in the title's own download0/profiles/10000000/logs/app.log):

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

Details in #3584. If you reopen this with that evidence it should meet the intake rules; I won't open a copy.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109704664 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1832#issuecomment-6109704664). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T13:48:53Z. --- @TideOPL a title now stops here on `main` (a11c8f7f): ProsperoTV (PPSA99003), right after its menu opens, polling the read end of a `pipe` (descriptor 3) next to its sockets. Log line (in the title's own `download0/profiles/10000000/logs/app.log`): ``` what(): poll: descriptor 3 is not a socket ``` Details in #3584. If you reopen this with that evidence it should meet the intake rules; I won't open a copy.

Pull request closed

Sign in to join this conversation.
No reviewers
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!1832
No description provided.