fix(libkernel): poll libSceNet sockets with the host wait #4933

Merged
nicolasfalesy merged 1 commit from upstream-pr/4933 into main 2026-10-14 19:02:57 +00:00
nicolasfalesy commented 2026-10-13 05:10:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T05:10:45Z.


What

Follow-up to #4924 (and #4391). With libSceNet sockets on ordinary descriptor numbers, poll on a libSceNet socket throws:

what():  poll: descriptor 47 is neither a socket nor a pipe

poll only knew libkernel sockets and pipes. select already handles libSceNet sockets through the poller libSceNet registers, but poll never asked it.

libSceNet now registers a native lookup with libkernel (KernelSetSocketNativeLookup_nid_no_patch), next to its poller, closer, option setter and status control. For a libSceNet descriptor it returns the host socket plus a shared_ptr owner that keeps that socket open. poll uses it when Find misses, and puts the host socket into the same WSAPoll / poll call as libkernel sockets, with the same flag mapping and the same Windows POLLPRI rule. So mixed sets (libkernel sockets, libSceNet sockets, pipes) need no second wait loop, and a concurrent sceNetSocketClose cannot close the host socket under the wait.

This branch contains #4391's and #4924's commits; the change here is the last commit (bc299f299).

Tested

Linux (Arch, GCC 16.2.1, Release), on #4924's head plus this commit:

  • guest_sce_net: new checks that poll on a libSceNet UDP socket reports nothing, then POLLIN after a datagram arrives, and that a set with one libkernel and one libSceNet socket reports POLLOUT on both. Without the Udp.cpp change it aborts with poll: descriptor 7 is neither a socket nor a pipe.
  • Full ctest: 1002 of 1002 pass (the 8 display-only VideoOut and AGC tests skip).
  • ProsperoLight (PPSA99002, catalog release, --to-intel), 3 runs of 60 s: no stop. On #4924 alone it aborted on the poll above. It now reaches its main screen ("Your PCs", "No PCs yet", Sunshine discovery running).
  • tools/check_conventions.py --base upstream/main passes.
  • Not tested on Windows. #4525 changes the same POLLPRI lines in poll; whichever lands second needs a small rebase.

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 under Silent stubs in their library's technical debt file
  • 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: #4924, #4391
  • Unblocks: PPSA99002 (ProsperoLight) on Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4838672944 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-13T05:10:45Z. --- ### What Follow-up to #4924 (and #4391). With libSceNet sockets on ordinary descriptor numbers, `poll` on a libSceNet socket throws: ``` what(): poll: descriptor 47 is neither a socket nor a pipe ``` `poll` only knew libkernel sockets and pipes. `select` already handles libSceNet sockets through the poller libSceNet registers, but `poll` never asked it. libSceNet now registers a native lookup with libkernel (`KernelSetSocketNativeLookup_nid_no_patch`), next to its poller, closer, option setter and status control. For a libSceNet descriptor it returns the host socket plus a `shared_ptr` owner that keeps that socket open. `poll` uses it when `Find` misses, and puts the host socket into the same `WSAPoll` / `poll` call as libkernel sockets, with the same flag mapping and the same Windows `POLLPRI` rule. So mixed sets (libkernel sockets, libSceNet sockets, pipes) need no second wait loop, and a concurrent `sceNetSocketClose` cannot close the host socket under the wait. **This branch contains #4391's and #4924's commits; the change here is the last commit (bc299f299).** ### Tested Linux (Arch, GCC 16.2.1, Release), on #4924's head plus this commit: - `guest_sce_net`: new checks that `poll` on a libSceNet UDP socket reports nothing, then `POLLIN` after a datagram arrives, and that a set with one libkernel and one libSceNet socket reports `POLLOUT` on both. Without the `Udp.cpp` change it aborts with `poll: descriptor 7 is neither a socket nor a pipe`. - Full `ctest`: 1002 of 1002 pass (the 8 display-only VideoOut and AGC tests skip). - ProsperoLight (PPSA99002, catalog release, `--to-intel`), 3 runs of 60 s: no stop. On #4924 alone it aborted on the `poll` above. It now reaches its main screen ("Your PCs", "No PCs yet", Sunshine discovery running). - `tools/check_conventions.py --base upstream/main` passes. - Not tested on Windows. #4525 changes the same `POLLPRI` lines in `poll`; whichever lands second needs a small rebase. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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: #4924, #4391 - [x] Unblocks: PPSA99002 (ProsperoLight) on Linux - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 08:20:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:20:52Z.


Windows test of this PR.

Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, BUILD_TESTING=ON, -j2, libusb-cmake from a local checkout. Built from main c2565f014 with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict.

Result: guest_dup and guest_fstatfs (2 of 2) pass.

Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141389097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933#issuecomment-6141389097). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T08:20:52Z. --- Windows test of this PR. Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `BUILD_TESTING=ON`, `-j2`, `libusb-cmake` from a local checkout. Built from `main` `c2565f014` with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict. Result: guest_dup and guest_fstatfs (2 of 2) pass. Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested. AI-assisted (Claude Code).
p3n1cillin commented 2026-10-13 16:46:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T16:46:04Z.


Title evidence for this PR: ProsperoLight (PPSA99002, catalog release) on Windows 11, MinGW GCC 15.2.0, Release, with the original eboot.bin staged in app0 (as #5040 documents; without it the title takes another path and never gets here).

  • On main (and on main plus my open libkernel PRs) it stops 3 to 5 s in, every run, right after [SOFT-NET] sceNetResolverStartNtoa -> host DNS lookup failed in its launcher log:
    what():  poll: descriptor 11 is neither a socket nor a pipe
    
    A local diagnostic build (not part of any PR) showed what descriptor 11 is: GetFileType = FILE_TYPE_CHAR, an empty final path, polled with POLLOUT among 2 descriptors. That is the NUL placeholder of a socket number that libkernel's own socket table doesn't know, so it is a libSceNet socket waiting for a connect.
  • With this PR merged: the title runs the whole 60 s run with no exception.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150551214 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933#issuecomment-6150551214). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T16:46:04Z. --- Title evidence for this PR: ProsperoLight (PPSA99002, catalog release) on Windows 11, MinGW GCC 15.2.0, Release, with the original `eboot.bin` staged in `app0` (as #5040 documents; without it the title takes another path and never gets here). - On `main` (and on `main` plus my open libkernel PRs) it stops 3 to 5 s in, every run, right after `[SOFT-NET] sceNetResolverStartNtoa -> host DNS lookup failed` in its launcher log: ``` what(): poll: descriptor 11 is neither a socket nor a pipe ``` A local diagnostic build (not part of any PR) showed what descriptor 11 is: `GetFileType` = `FILE_TYPE_CHAR`, an empty final path, polled with `POLLOUT` among 2 descriptors. That is the `NUL` placeholder of a socket number that libkernel's own socket table doesn't know, so it is a libSceNet socket waiting for a connect. - With this PR merged: the title runs the whole 60 s run with no exception. AI-assisted (Claude Code).
Sevthered commented 2026-10-13 21:53:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sevthered on 2026-10-13T21:53:47Z.


Tested on Windows with a second title: OpenNOW PS5 0.1 (PPSA99082, catalog release, eboot.bin and sce_module/libc.prx unwrapped from their SELF containers, relinked with --windows). Windows 11, RTX 3080 Ti (NVIDIA 616.56), WinLibs GCC 15.2.0 r7, Release.

On main 665ad7da7 it stops a few seconds after start-up:

terminate called after throwing an instance of 'std::runtime_error'
  what():  poll: descriptor 7 is neither a socket nor a pipe

Descriptor 7 is the title's non-blocking TCP socket made through libSceNet (its log: socket domain=2 type=536870913 protocol=6, socket result=7, then a connect that returns EINPROGRESS).

With #4924 and this PR cherry-picked onto 665ad7da7 (both apply cleanly) the throw is gone and the title keeps running. Its requests then fail with curl=7 os_errno=45, the missing SO_ERROR that #4988 adds. With #4988 as well it runs the full 60 s, no request fails and its decoder qualification completes (GPU qualification profile=4K120 SDR / HARDWARE / 100 MBPS ... qualified=1).

So this also unblocks PPSA99082 on Windows.

One note for whoever merges second: #4924 and #4988 conflict in core/libs/tests/GuestSceNet.cpp, where each adds a call after CheckKernelTimeouts(); (CheckKernelStatusFlags(); and CheckSocketError();). Keeping both lines resolves it.

AI-assisted: yes (Claude Code); the runs are from my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155997708 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933#issuecomment-6155997708). Originally posted by [Sevthered](https://github.com/Sevthered) on 2026-10-13T21:53:47Z. --- Tested on Windows with a second title: OpenNOW PS5 0.1 (PPSA99082, catalog release, `eboot.bin` and `sce_module/libc.prx` unwrapped from their SELF containers, relinked with `--windows`). Windows 11, RTX 3080 Ti (NVIDIA 616.56), WinLibs GCC 15.2.0 r7, Release. On `main` `665ad7da7` it stops a few seconds after start-up: ``` terminate called after throwing an instance of 'std::runtime_error' what(): poll: descriptor 7 is neither a socket nor a pipe ``` Descriptor 7 is the title's non-blocking TCP socket made through libSceNet (its log: `socket domain=2 type=536870913 protocol=6`, `socket result=7`, then a connect that returns `EINPROGRESS`). With #4924 and this PR cherry-picked onto `665ad7da7` (both apply cleanly) the throw is gone and the title keeps running. Its requests then fail with `curl=7 os_errno=45`, the missing `SO_ERROR` that #4988 adds. With #4988 as well it runs the full 60 s, no request fails and its decoder qualification completes (`GPU qualification profile=4K120 SDR / HARDWARE / 100 MBPS ... qualified=1`). So this also unblocks PPSA99082 on Windows. One note for whoever merges second: #4924 and #4988 conflict in `core/libs/tests/GuestSceNet.cpp`, where each adds a call after `CheckKernelTimeouts();` (`CheckKernelStatusFlags();` and `CheckSocketError();`). Keeping both lines resolves it. AI-assisted: yes (Claude Code); the runs are from my machine.
dantdmdarealguy commented 2026-10-14 05:45:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-14T05:45:36Z.


Windows 11 Pro, Intel Core i9-14900K, 128 GB, NVIDIA GeForce RTX 5080 (driver 32.0.16.1714), WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. Head 47dc519e50 (with #4924's fb085e616) and its merge base 0f2683cb7d, each built in the same build directory. ProsperoLight (PPSA99002, catalog release), eboot.bin and sce_module/libc.prx unwrapped, relinked from each build with relinker --windows --registry, original eboot.bin kept in app0, fresh run directory per build.

Tests

  • Head: guest_sce_net passes 5 of 5 (--repeat until-fail:5). The head's GuestSceNet.cpp with the libraries at fb085e616 (#4924 alone, without this PR's Export.cpp, Socket.cpp, SocketPoll.hpp and Udp.cpp) aborts:
    what():  poll: descriptor 3 is neither a socket nor a pipe
    
    So the new checks fail without the change.
  • Head and base: guest_sce_net, guest_poll, guest_udp, guest_tcp, all guest_socket_*, guest_kernel_fcntl and patched_libraries (23 tests): 23 of 23 pass on both.
  • The incremental head build has no warnings. tools/check_conventions.py --base 0f2683cb7d and tools/check_test_registration.py pass.

ProsperoLight, 60 s runs

  • Base, 3 of 3 runs exit 0xC0000409 after 8.0 to 9.8 s:
    what():  poll: descriptor 11 is neither a socket nor a pipe
    
  • Head, 3 of 3 runs last the full 60 s with no exception, then close with exit 0 on WM_CLOSE. The title reaches its main screen ("Your PCs", "No PCs yet", "1080p · 60 FPS"). Window title FPS at 57 s: 42.71, 33.45, 41.00. The launcher log has no failure line; its submit counters report failures=0.

The head's main screen at 57 s:

ProsperoLight main screen at 57 s

The branch no longer merges cleanly into main a14ae8e23: core/libs/tests/GuestSceNet.cpp conflicts. The library files merge without conflicts.

Verdict: works on Windows. The ProsperoLight stop is gone, and the new test fails without the library change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161807009 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933#issuecomment-6161807009). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-14T05:45:36Z. --- Windows 11 Pro, Intel Core i9-14900K, 128 GB, NVIDIA GeForce RTX 5080 (driver 32.0.16.1714), WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`. Head `47dc519e50` (with #4924's `fb085e616`) and its merge base `0f2683cb7d`, each built in the same build directory. ProsperoLight (PPSA99002, catalog release), `eboot.bin` and `sce_module/libc.prx` unwrapped, relinked from each build with `relinker --windows --registry`, original `eboot.bin` kept in `app0`, fresh run directory per build. **Tests** - Head: `guest_sce_net` passes 5 of 5 (`--repeat until-fail:5`). The head's `GuestSceNet.cpp` with the libraries at `fb085e616` (#4924 alone, without this PR's `Export.cpp`, `Socket.cpp`, `SocketPoll.hpp` and `Udp.cpp`) aborts: ``` what(): poll: descriptor 3 is neither a socket nor a pipe ``` So the new checks fail without the change. - Head and base: `guest_sce_net`, `guest_poll`, `guest_udp`, `guest_tcp`, all `guest_socket_*`, `guest_kernel_fcntl` and `patched_libraries` (23 tests): 23 of 23 pass on both. - The incremental head build has no warnings. `tools/check_conventions.py --base 0f2683cb7d` and `tools/check_test_registration.py` pass. **ProsperoLight, 60 s runs** - Base, 3 of 3 runs exit `0xC0000409` after 8.0 to 9.8 s: ``` what(): poll: descriptor 11 is neither a socket nor a pipe ``` - Head, 3 of 3 runs last the full 60 s with no exception, then close with exit 0 on WM_CLOSE. The title reaches its main screen ("Your PCs", "No PCs yet", "1080p · 60 FPS"). Window title FPS at 57 s: 42.71, 33.45, 41.00. The launcher log has no failure line; its submit counters report `failures=0`. The head's main screen at 57 s: ![ProsperoLight main screen at 57 s](https://raw.githubusercontent.com/dantdmdarealguy/AnyPS5/pr-assets/pr4933/main-screen-57s.png) The branch no longer merges cleanly into `main` `a14ae8e23`: `core/libs/tests/GuestSceNet.cpp` conflicts. The library files merge without conflicts. Verdict: works on Windows. The ProsperoLight stop is gone, and the new test fails without the library change.
p3n1cillin commented 2026-10-14 12:02:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-14T12:02:07Z.


Another title that stops here: OpenNOW PS5 Prototype (PPSA99082, catalog release), on Windows 11, MinGW GCC 15, Release.

It doesn't reach this idle. With menu input (Enter/arrow key presses sent to its window), it opens /data/opennow/account.bin and network.log, then stops about 10 s in on main 1209d3707:

what():  poll: descriptor 7 is neither a socket nor a pipe

A local log at that throw showed events=0x4 (POLLOUT) and count=2, and descriptor 7's host handle has GetFileType = FILE_TYPE_CHAR. That's the NUL placeholder libSceNet sockets hold on Windows, so it's the case this PR handles.

With this PR merged onto the same main, the same input runs for the whole 90 s with no stop. The merge conflicts in GuestSceNet.cpp and docs/dev/debt/libkernel.md; I took this PR's side for both for the run.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167870059 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933#issuecomment-6167870059). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-14T12:02:07Z. --- Another title that stops here: OpenNOW PS5 Prototype (PPSA99082, catalog release), on Windows 11, MinGW GCC 15, Release. It doesn't reach this idle. With menu input (Enter/arrow key presses sent to its window), it opens `/data/opennow/account.bin` and `network.log`, then stops about 10 s in on `main` `1209d3707`: ``` what(): poll: descriptor 7 is neither a socket nor a pipe ``` A local log at that throw showed `events=0x4` (POLLOUT) and `count=2`, and descriptor 7's host handle has `GetFileType` = `FILE_TYPE_CHAR`. That's the `NUL` placeholder libSceNet sockets hold on Windows, so it's the case this PR handles. With this PR merged onto the same `main`, the same input runs for the whole 90 s with no stop. The merge conflicts in `GuestSceNet.cpp` and `docs/dev/debt/libkernel.md`; I took this PR's side for both for the run. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-14 18:00:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:00:30Z.


Rebased onto current main: dropped the fcntl commit (already merged as #4924) and resolved the docs/dev/debt/libkernel.md poll line. Build and tests for libSceNet/libkernel are green (173/173), and guest_sce_net fails without the change. Merging once the full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174899570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933#issuecomment-6174899570). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T18:00:30Z. --- Rebased onto current `main`: dropped the `fcntl` commit (already merged as #4924) and resolved the `docs/dev/debt/libkernel.md` poll line. Build and tests for libSceNet/libkernel are green (173/173), and `guest_sce_net` fails without the change. Merging once the full build is green.
github-actions[bot] commented 2026-10-14 18:02:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T18:02:21Z.


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
#5973 docs/dev/debt/libkernel.md L165
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174934556 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4933#issuecomment-6174934556). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T18:02:21Z. --- <!-- 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 | |---|---|---|---| | #5973 | `docs/dev/debt/libkernel.md` [L165](https://github.com/boykopovar/AnyPS5/blob/fd6c5ad9c185c389ee88cd5d5efaf29a11f86b92/docs/dev/debt/libkernel.md#L165) | | |
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!4933
No description provided.