Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
nicolasfalesy:fix/libkernel-poll-scenet-sockets
Oct 14, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
nicolasfalesy:fix/libkernel-poll-scenet-sockets

Conversation

@nicolasfalesy

Copy link
Copy Markdown
Contributor

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 (bc299f2).

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 fix(libkernel): answer fcntl status flags on libSceNet sockets #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. fix(libkernel): support POLLPRI on Windows sockets #4525 changes the same POLLPRI lines in poll; whichever lands second needs a small rebase.

Checklist

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
dantdmdarealguy added a commit to dantdmdarealguy/AnyPS5 that referenced this pull request Oct 14, 2026
@dantdmdarealguy

Copy link
Copy Markdown
Contributor

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 (fix(libkernel): answer fcntl status flags on libSceNet sockets #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.

@p3n1cillin

Copy link
Copy Markdown
Contributor

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)

@Ondra97 Ondra97 mentioned this pull request Oct 14, 2026
11 tasks done
@adriadam10 adriadam10 self-assigned this Oct 14, 2026
With libSceNet sockets on ordinary descriptor numbers (#4391), poll on a
libSceNet socket threw "neither a socket nor a pipe": poll only knew
libkernel sockets and pipes, while select already asks libSceNet through
its poller. libSceNet now lends libkernel the host socket behind a
descriptor, together with an owner that keeps it open, so poll puts it in
the same WSAPoll or poll call as libkernel sockets. ProsperoLight
(PPSA99002) stopped here on Linux and now reaches its PC list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EvDbpwUPTa78oCAJqe7m9K
@adriadam10
adriadam10 force-pushed the fix/libkernel-poll-scenet-sockets branch from 47dc519 to 62d8eea Compare October 14, 2026 18:00
@adriadam10

Copy link
Copy Markdown
Collaborator

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

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

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

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@adriadam10
adriadam10 merged commit 16d7ad0 into boykopovar:main Oct 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants