Skip to content

fix(libkernel): forward socket calls on sceNetSocket descriptors to libSceNet - #14310

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
XatiX:fix/libkernel-net-socket-forwards
Nov 3, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
XatiX:fix/libkernel-net-socket-forwards

Conversation

@XatiX

@XatiX XatiX commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What

A title can create a socket with sceNetSocket and then call bind, getsockname, sendto or recvfrom from libkernel. libkernel does not hold that descriptor, so these calls failed with EBADF.

libSceNet now registers the four calls with libkernel, in the same shape #9515 used for getsockopt: libkernel asks only for a descriptor it does not hold, and any descriptor libSceNet does not own still reports EBADF. Each call runs libkernel's validation before it forwards, so a forwarded descriptor keeps the libkernel contract: the same errors, safe guest-address handling and MSG_WAITALL. The differences that remain are in the debt entry.

This is what stopped PPSA06866. RakNet opens its socket through sceNetSocket, so the title's local server failed with AbstractPeer::Init: Failed to bind socket to port in range 0 - 0, and the load after difficulty selection never ended.

Tested

Windows 11 Pro 10.0.26300, GCC 15.2.0 (WinLibs).

  • guest_sce_net_kernel_forwards runs one set of checks through the libkernel calls on sockets from both socket() and sceNetSocket: a loopback datagram, null arguments, address lengths, unreadable pointers, flags, a zero-length receive, and stream MSG_WAITALL across two sends and end of stream. It also checks unknown descriptors. It passes. Against the previous forwarding code it fails at the first null bind on a forwarded socket.
  • 58 of 58 tests matching guest_sce_net|guest_net|net_epoll|guest_udp|guest_socket|guest_tcp|guest_datagram pass on main f2d874c1fd.
  • PPSA06866: plain main stops earlier, at the unsupported stencil copy, so the title cannot reach this code there. On a local branch that also carries feat(agc): sample the stencil plane of a native multisampled D32S8 target #9717 and feat(agc): publish a written native multisample D32S8 surface to its guest planes on a guest read #13021 plus this commit, the title started its local server and reached play, with no bind failure in its network.log and the local client connected. That branch differs from this one. It is not evidence that the title runs on main.
  • Connection-side calls such as connect and listen are not forwarded. The title does not need them and they are not tested.

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: none
  • Fixes: none
  • Unblocks: PPSA06866 Divinity: Original Sin II Definitive Edition (PPSA06866) #13726, a later stop; the title stops earlier on main
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

The forwarding implementation is scoped, but it conflicts with two open socket PRs and the repository requires the authors to coordinate their landing order.

What I ran

Reviewed head c061c4391bd8e3ead28c0077c0d4a329ca068490 against PR base 5c9837bfe7c5533f2c77c968dd8193157a8c342a. The stack precheck also previewed it cleanly against current main 26fa1212b82f76dd49cf12d65e445d6ff3e0844c. Pairwise previews used #9948 head 52566995bb14259fd9b1da51fb7879a523ce1ef8 (merge base 3fea2a937ba9fbab2f06c51691fe0c5763659aa3) and #11281 head 09746b556e6fca208357b1cb60c397a5e06125a8 (merge base acb900c194325b9ee8c23c10768a9a491454f0b2). Those previews conflict in SocketPoll.hpp and Udp.cpp, respectively. Environment: Linux 6.1.0-54-amd64; no compiler was invoked. I did not configure, build, or run local CTest.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14310
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 5c9837bfe7c5533f2c77c968dd8193157a8c342a --head c061c4391bd8e3ead28c0077c0d4a329ca068490 --json
python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14310-c061c4391bd8/head-c061c4391bd8-94ae5610 --json core/libs/tests/GuestNetKernelForwards.cpp
git fetch https://github.com/boykopovar/AnyPS5.git refs/pull/14310/head:refs/review/new-pr/14310-20261101
git fetch https://github.com/boykopovar/AnyPS5.git refs/pull/9948/head:refs/review/new-pr/9948-20261101
git fetch https://github.com/boykopovar/AnyPS5.git refs/pull/11281/head:refs/review/new-pr/11281-20261101
git merge-tree --write-tree refs/review/new-pr/14310-20261101 refs/review/new-pr/9948-20261101
git merge-tree --write-tree refs/review/new-pr/14310-20261101 refs/review/new-pr/11281-20261101
gh pr checks 14310 --repo boykopovar/AnyPS5
gh run view 41288244640 --repo boykopovar/AnyPS5 --job 124794866407 --log | grep -E 'guest_sce_net_kernel_forwards|guest_sce_net.*(Passed|Skipped)|100% tests passed|tests failed out of' | tail -20

Results

Check Result
Diff check Passed in the exact-head precheck.
Conventions and PR template Passed in the exact-head precheck and hosted CI.
Export/ABI audit No changed export ABI was identified. Its RunNetThread declaration warning is outside this diff; the symbol is unchanged.
Test-quality heuristic Possible-unregistered-test warning; false positive because this CMakeLists explicitly adds GuestNetKernelForwards.cpp as a test executable and registers guest_sce_net_kernel_forwards.
Mergeability with current main Clean in the stack precheck.
Pairwise overlap with open PRs #9948 conflicts in SocketPoll.hpp; #11281 conflicts in Udp.cpp.
Hosted checks Conventions, intake, labels, eligibility, portability, report and Windows passed. The changed guest_sce_net_kernel_forwards test passed in the Windows CTest run. Linux and specialized jobs were skipped.
Local build/CTest Not run.

The precheck's aggregate status was checks failed because its detached exact-head checkout does not contain the workspace-only ABI and test-quality helper scripts. I reran the applicable helpers from the workspace and inspected their findings against the exact-head diff and CMake registration.

Unedited output excerpts from the relevant checks
All conventions checks passed.

{
  "status": "passed_with_warnings",
  "findings": [
    {
      "symbol": "RunNetThread",
      "kind": "public-declaration-not-found",
      "message": "No APS5_VABI declaration was found in a header; verify whether this is intentionally private or missing from the public interface."
    }
  ]
}
{
  "findings": [
    {
      "path": "core/libs/tests/GuestNetKernelForwards.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}
CONFLICT (content): Merge conflict in core/libs/prx/libkernel/Socket/include/SocketPoll.hpp
CONFLICT (content): Merge conflict in core/libs/prx/libkernel/Socket/src/Udp.cpp
windows	Build and run changed guest core/libs tests	2026-11-01T09:00:56.7252124Z 1903/2582 Test #2365: guest_sce_net_kernel_forwards ............................................   Passed    0.02 sec
windows	Build and run changed guest core/libs tests	2026-11-01T09:02:16.2379437Z 100% tests passed, 0 tests failed out of 2582

Negative control

Assertion Change to code under test Did the new test fail?
Forwarded socket success/error paths on sceNetSocket descriptors No mutation was made; I did not run a negative control locally; the author-reported registration-removal result was not independently repeated. Could not exercise during this review.

Findings

Blocking

  1. Coordinate the overlapping socket changes. Both #9948 and #11281 are still open. Pairwise previews of this head with their exact current heads conflict in files this PR changes: SocketPoll.hpp with #9948 and Udp.cpp with #11281. The repository says authors of overlapping PRs should agree which goes first and declare that order with Depends on; this PR currently says Depends on: none. Please coordinate with both authors and update the dependency/landing-order line and branch so the changes integrate cleanly.

Non-blocking

  • The test-quality warning is heuristic-only and is resolved by the explicit CMake target and CTest registration in this PR.

Sources

Not verified

  • A local build or CTest run; the exact-head Windows CI job did build and pass its test suite.
  • The author's prior-base test runs and title-specific behavior were not independently reproduced here.
  • Linux and other platform behavior; the hosted Linux job was skipped.

To get this to a good state

Coordinate the order with #9948 and #11281, declare any resulting dependency, and update the branch to integrate with the chosen order. I will re-check the new head, repeat the no-build checks, and inspect the CI result for the updated head.

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line libkernel build prx labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 5836 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7485 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7490 core/libs/prx/libSceNet/Export.cpp
PR 7532 docs/dev/debt/libkernel.md
PR 7565 docs/dev/debt/libkernel.md
PR 7804 docs/dev/debt/libkernel.md
PR 8448 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8463 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8497 docs/dev/debt/libkernel.md
PR 8605 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 9156 docs/dev/debt/libkernel.md
PR 9199 docs/dev/debt/libkernel.md
PR 9242 docs/dev/debt/libkernel.md
PR 9293 docs/dev/debt/libkernel.md
PR 9297 docs/dev/debt/libkernel.md
PR 9302 docs/dev/debt/libkernel.md
PR 9326 docs/dev/debt/libkernel.md
PR 9389 docs/dev/debt/libkernel.md
PR 9557 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9684 docs/dev/debt/libkernel.md
PR 9713 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9843 docs/dev/debt/libkernel.md
PR 9938 docs/dev/debt/libkernel.md
PR 9947 docs/dev/debt/libkernel.md
PR 9948 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/include/SocketPoll.hpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10025 docs/dev/debt/libkernel.md
PR 10192 docs/dev/debt/libkernel.md
PR 10319 docs/dev/debt/libkernel.md
PR 10442 docs/dev/debt/libkernel.md
PR 10558 docs/dev/debt/libkernel.md
PR 10629 core/libs/prx/libSceNet/Export.cpp
PR 10645 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 10749 docs/dev/debt/libkernel.md
PR 11002 docs/dev/debt/libkernel.md
PR 11215 docs/dev/debt/libkernel.md
PR 11219 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 11223 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 11247 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 11272 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 11559 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 11571 core/libs/prx/libSceNet/Export.cpp
PR 11624 docs/dev/debt/libkernel.md
PR 11625 docs/dev/debt/libkernel.md
PR 11628 docs/dev/debt/libkernel.md
PR 11661 docs/dev/debt/libkernel.md
PR 11689 docs/dev/debt/libkernel.md
PR 11698 docs/dev/debt/libkernel.md
PR 11896 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 11939 docs/dev/debt/libkernel.md
PR 12104 docs/dev/debt/libkernel.md
PR 12170 docs/dev/debt/libkernel.md
PR 12560 docs/dev/debt/libkernel.md
PR 12646 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 12682 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 12683 core/libs/prx/libSceNet/Export.cpp
PR 12688 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 12700 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 12854 docs/dev/debt/libkernel.md
PR 12918 core/libs/prx/libSceNet/Export.cpp
PR 12965 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 12970 docs/dev/debt/libkernel.md
PR 13098 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 13336 docs/dev/debt/libkernel.md
PR 13504 docs/dev/debt/libkernel.md
PR 13506 docs/dev/debt/libkernel.md
PR 13560 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 13582 docs/dev/debt/libkernel.md
PR 13587 docs/dev/debt/libkernel.md
PR 13664 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 13695 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 13752 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 13950 docs/dev/debt/libkernel.md
PR 13953 docs/dev/debt/libkernel.md
PR 13964 docs/dev/debt/libkernel.md
PR 13995 docs/dev/debt/libkernel.md
PR 14009 core/libs/prx/libSceNet/Export.cpp
PR 14039 docs/dev/debt/libkernel.md
PR 14043 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 14085 docs/dev/debt/libkernel.md
PR 14103 docs/dev/debt/libkernel.md
PR 14105 docs/dev/debt/libkernel.md
PR 14108 docs/dev/debt/libkernel.md
PR 14111 docs/dev/debt/libkernel.md
PR 14128 docs/dev/debt/libkernel.md
PR 14183 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 14190 docs/dev/debt/libkernel.md
PR 14206 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 14212 docs/dev/debt/libkernel.md
PR 14213 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 14244 core/libs/prx/libSceNet/Export.cpp
PR 14250 core/libs/prx/libSceNet/Export.cpp
PR 14264 docs/dev/debt/libkernel.md
PR 14320 docs/dev/debt/libkernel.md
PR 14324 docs/dev/debt/libkernel.md
PR 14325 docs/dev/debt/libkernel.md
PR 14417 docs/dev/debt/libkernel.md
PR 14493 docs/dev/debt/libkernel.md
PR 14497 docs/dev/debt/libkernel.md
PR 14710 docs/dev/debt/libkernel.md
PR 14756 docs/dev/debt/libkernel.md
PR 14832 docs/dev/debt/libkernel.md
PR 14846 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 14854 docs/dev/debt/libkernel.md
PR 14875 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 14876 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 14885 docs/dev/debt/libkernel.md
PR 14886 docs/dev/debt/libkernel.md
PR 14894 docs/dev/debt/libkernel.md
PR 14902 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 14970 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 15030 docs/dev/debt/libkernel.md
PR 15035 docs/dev/debt/libkernel.md
PR 15037 docs/dev/debt/libkernel.md
PR 15040 docs/dev/debt/libkernel.md
PR 15041 docs/dev/debt/libkernel.md
PR 15064 docs/dev/debt/libkernel.md
PR 15076 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
PR 15095 docs/dev/debt/libkernel.md

@XatiX

XatiX commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Updated to 416f02b702 on main 26fa1212b8. 32 of 32 tests matching guest_sce_net|guest_udp|guest_socket pass there, including guest_sce_net_kernel_forwards.

#9948. I moved the declarations in SocketPoll.hpp, so the head now merges with it without conflict.

#11281. This one cannot be moved. Both changes have to go at the top of getsockname, because the forward has to run before Lookup fails. It is a small rebase for whichever lands second: #11281's length copy-in first, then this PR's forward check. That keeps its EFAULT ahead of the descriptor lookup. Neither needs the other, so Depends on stays none. I have said the same on #11281.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Reviewed at c061c4391b; the PR's own changes are unchanged at the current head 416f02b702. Please preserve the libkernel call contract when forwarding, and add tests comparing sockets created through both APIs.

The new callbacks in libkernel/Socket/src/Udp.cpp:1553,1606,1669-1671,1709-1711 run before libkernel validation and directly use the libSceNet entry points. Those entry points do not have identical argument semantics. For example, the kernel path returns EFAULT for a null getsockname output and for a nonempty transfer with a null buffer, while sceNetGetsockname, sceNetSendto and sceNetRecvfrom return EINVAL. The new test at GuestNetKernelForwards.cpp:55 expects that libSceNet-specific EINVAL from the libkernel call. Please preserve the kernel error at the forwarding boundary and adjust the test, or provide platform evidence establishing the differing kernel contract for these descriptors.

Please also preserve the kernel wrapper's supported receive flags and guest-address handling. The kernel recvfrom path accepts MSG_WAITALL and safely copies its address-length input; sceNetRecvfrom rejects MSG_WAITALL and follows a different address-output path. The new forwarding applies to stream descriptors as well as datagrams, although the regression exercises only datagrams. Add targeted kernel-contract coverage for null arguments, address-length handling and a supported stream receive flag, alongside the successful loopback datagram. Keep genuine invalid-argument tests; no unimplemented-throw assertion needs to be added.

The callback registration and conversion of negative network results into -1 plus guest errno otherwise follow the existing bridge pattern. This request concerns the newly exposed libkernel boundary, rather than requiring a rewrite of all existing libSceNet callers.

@XatiX
XatiX force-pushed the fix/libkernel-net-socket-forwards branch from 416f02b to 6f42aeb Compare November 1, 2026 17:46
@XatiX

XatiX commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@oneandonlydean
Addressed in dbe6e66037, on main f2d874c1fd. I took the first option: the forwarded calls now keep the libkernel contract, so no platform evidence is needed. The debt entry for these hooks already records that on the console both APIs share one kernel descriptor space.

Boundary. bind, getsockname, sendto and recvfrom now run libkernel's own validation first and only then forward. libSceNet reports the socket's family through a new family callback, so bind and sendto use the existing Address check unchanged.

  • Null arguments return EFAULT, and the test at GuestNetKernelForwards.cpp:55 that expected EINVAL is gone.
  • Address errors match libkernel: 63 above 255 bytes, 22 for a wrong length, 47 for a wrong family.
  • sendto forwards the copied destination, so an unreadable address returns EFAULT instead of being read directly.
  • recvfrom copies the length in safely, receives into a local name, and reports it through ReportAddress.

Receive flags. MSG_WAITALL is accepted. On a stream it is a loop of sceNetRecvfrom calls in the libSceNet callback, ending when the buffer is full, at end of stream or on an error. The flag is dropped for datagrams, as NativeReceiveFlags does, and with MSG_PEEK, where a loop would read the same bytes again. Public sceNetRecvfrom still rejects it.

Zero length. A zero-length receive on an idle datagram socket now returns 0, as libkernel's does. It blocked before; the test timed out with that check removed.

Tests. guest_sce_net_kernel_forwards now runs one set of checks against sockets from socket() and from sceNetSocket: the loopback datagram, null arguments, address lengths, unreadable pointers, flags, and a stream MSG_WAITALL across two sends and across end of stream.

  • The one difference: MSG_PEEK | MSG_WAITALL runs only on the sceNetSocket socket, because it fails with errno 45 on a libkernel socket on Windows. That is an existing limit of the libkernel path, which I did not change. The Winsock cause is my reading, not confirmed.
  • Against the previous forwarding code, the test fails at the first null bind on a forwarded socket.
  • 58 of 58 tests matching guest_sce_net|guest_net|net_epoll|guest_udp|guest_socket|guest_tcp|guest_datagram pass, on Windows 11 with GCC 15.2.0.
  • I ran the title on a local branch carrying this commit: PPSA06866 reached play with no bind failure in its network.log, and the local client connected.

Still different, recorded in the entry in docs/dev/debt/libkernel.md, which also needed updating for this PR: sendto to port 0 does not get libkernel's answer on a libSceNet socket, sendto with a destination on a connected stream is not ignored, and a bind to an over-long IPv4-mapped address is refused.

@MarcZX10: your review. The overlap you flagged is covered in my earlier comment: #9948 merges cleanly, and #11281 stays a small rebase for whichever lands second. This change does not alter that order: the getsockname forward still sits at the top of the function, and the rebase keeps #11281's length copy-in ahead of it.

JamesPSlater and others added 2 commits November 2, 2026 17:32
…ibSceNet

A title can create a socket with sceNetSocket and then call bind, getsockname, sendto or recvfrom from libkernel, which does not hold that descriptor, so the call failed with EBADF. PPSA06866's RakNet does this, its local server fails to start and the load after difficulty selection never ends. libSceNet now registers these four calls with libkernel, as it does for setsockopt and getsockopt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bind, getsockname, sendto and recvfrom validate as for a libkernel socket
before they reach libSceNet, so a forwarded descriptor reports the same
errors. recvfrom keeps its guest address handling and MSG_WAITALL, and a
zero-length datagram receive does not wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XatiX

XatiX commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main bc12e15225 as 91311f1bf4 and 7a4fa3865b. #11281 merged, so getsockname now copies the length in first. The forwarded call follows it: it receives into a local name and writes the address and length out through the same safe copy that #11281 added for libkernel's sockets. 62 of 62 tests matching guest_sce_net|guest_net|net_epoll|guest_udp|guest_socket|guest_tcp|guest_datagram pass, including the four new guest_net_sendmsg_fault tests from main.

@XatiX
XatiX requested a review from MarcZX10 November 2, 2026 18:23
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 2, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

The six-file change has no blocking source defect in the reviewed head; I am withholding approval because the Linux runtime path was skipped and this change adds Linux socket forwarding behavior.

What I ran

Reviewed every changed file at head 7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98, against PR base a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. The stack precheck reported a clean merge preview against current main at that same base. Final refresh confirmed the PR remained open at the same head and base.

Environment: Debian 12, Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0 (not used for a build).

git diff --check a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8...7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14310 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14310-7a4fa3865bbf
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8 --head 7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98 --json
python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14310-7a4fa3865bbf/head-7a4fa3865bbf-c95a02fe --json core/libs/tests/GuestNetKernelForwards.cpp
gh pr checks 14310 --repo boykopovar/AnyPS5

The ABI audit and test-quality helper were rerun from the workspace because those optional scripts are absent from the isolated PR snapshot used by the precheck. I confirmed the test is registered in the changed CMake file despite the heuristic warning. I did not configure or build AnyPS5, run local CTest, or run a negative control.

Results

Check Result Note
Diff and conventions passed No whitespace errors; conventions and PR template pass.
Export audit passed 262 symbols scanned; one private-helper warning.
Merge preview passed Clean against current main.
Hosted Windows passed Exact head; new forwarding test passed.
Hosted Linux and specialized jobs not run Skipped by the workflow.
Precheck failed Optional audit scripts are absent from its isolated snapshot; both were run separately.
Local build, CTest and negative control not run The no-build review did not produce an exact-head binary.
Precheck summary and selected raw outputs

Precheck table (from its report):

Check Status Note
Build and compile not applicable Precheck does not build.
Diff check passed Exact base and head.
Conventions and PR template passed Exact head.
Changed-export ABI audit failed Helper script absent from isolated snapshot.
Python checks not applicable No changed Python files.
Dependency and mergeability passed Clean preview; no declared dependencies.
Build-dependent C++ tests not applicable Require an exact-head build.
Test-quality heuristic failed Helper script absent from isolated snapshot.
Negative controls not applicable No changed Python test module for a no-build control.

Conventions output:

All conventions checks passed.

Standalone ABI audit summary:

passed_with_warnings symbols 262 findings 1
{'symbol': 'RunNetThread', 'kind': 'public-declaration-not-found', 'message': 'No APS5_VABI declaration was found in a header; verify whether this is intentionally private or missing from the public interface.'}

Test-quality output (the CMake registration was manually confirmed):

{
  "findings": [
    {
      "path": "core/libs/tests/GuestNetKernelForwards.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

Hosted Windows log for the new test:

2026-11-02T18:18:21.3023749Z           Start 2749: guest_sce_net_kernel_forwards
2026-11-02T18:18:21.5710287Z 2251/2967 Test #2749: guest_sce_net_kernel_forwards ....................................................................   Passed    0.27 sec
2026-11-02T18:19:39.3497315Z 100% tests passed, 0 tests failed out of 2967

gh pr checks reported pass for conventions, labels, library-portability, report, eligibility and Windows; Linux, relinker, ASan, edge-watch, register-context and write-watch were skipping.

Negative control

Assertion Change to code under test Did the new test fail?
The forwarding test detects a regression in the new libkernel-to-libSceNet callbacks. No mutation was made; the exact-head C++ test was not run locally. Not exercised.

Findings

Blocking

None found in the six changed files.

Non-blocking

  • Please provide a Linux run of guest_sce_net_kernel_forwards on this head before approval. The Windows job passed, but Linux execution of the new forwarding and socket handling was skipped; the author's Linux test evidence is for main, not this change.

Sources

Not verified

  • Linux, macOS and PS5 console runtime behavior for this head.
  • A local C++ build, CTest run or negative control. The Windows result is hosted CI, not a local run.

To get this to a good state

Run ctest --test-dir build -R '^guest_sce_net_kernel_forwards$' --output-on-failure on Linux at this head and provide the result. I will recheck the current head and repeat the no-build review checks if the PR changes.

@XatiX

XatiX commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Here is a Linux run at this head, 7a4fa3865b. I can't start the project's Linux job myself, and Actions don't run on my fork, so I ran it locally instead.

Setup. WSL2 on Windows 11 (kernel 6.18.54.1-microsoft-standard-WSL2), Ubuntu 24.04.5 LTS, GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1. It was a fresh clone of boykopovar/AnyPS5 with pull/14310/head checked out at 7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98, with no local changes. Configure flags are the same as the Linux CI job: -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++. The packages are the ones release.yml installs. It is WSL2, not bare-metal Linux; the socket calls go to the Linux kernel's network stack inside the WSL2 VM.

Results.

  • ctest -R '^guest_sce_net_kernel_forwards$' -V: passed (0.21 s). This runs the forwarded bind, getsockname, sendto and recvfrom checks on sockets from both socket() and sceNetSocket, including stream MSG_WAITALL and the zero-length receive.
  • ctest -R 'guest_sce_net|guest_net|net_epoll|guest_udp|guest_socket|guest_tcp|guest_datagram': 51 of 51 passed, with none skipped or not run. Linux registers 51 of these tests; Windows registers 62, because some are Windows-only.

Logs attached: linux-forwards-ctest.log, linux-net-ctest.log and environment.txt.

environment.txt
linux-forwards-ctest.log
linux-net-ctest.log

@XatiX
XatiX requested a review from MarcZX10 November 2, 2026 19:14

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — same head, changes requested

The supplied Linux logs address the skipped runtime path, but the current head of open PR #9948 conflicts with this PR's debt-file edit and no landing order is recorded.

What I ran

Rechecked PR #14310 at head 7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98 against base a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. The full six-file source review was posted earlier on this same head; this follow-up verifies the newly supplied Linux logs and the live overlap with #9948. Both PRs merge individually into current main, but the pairwise preview conflicts in docs/dev/debt/libSceNet.md. Environment: Debian Linux x86_64, Git 2.39.5. I did not build locally.

gh pr checks 14310 --repo boykopovar/AnyPS5
git merge-tree --write-tree refs/review-session-20261102/main refs/review-session-20261102/pr14310
git merge-tree --write-tree refs/review-session-20261102/main refs/review-session-20261102/pr9948
git merge-tree --write-tree refs/review-session-20261102/pr14310 refs/review-session-20261102/pr9948

Results

Check Result Note
Windows hosted build and tests passed Exact head; all 2,967 tests passed, including the new forwarding test.
Linux focused and network tests passed Author-provided WSL2 logs show 1/1 and 51/51 passing; not run by me.
Each PR against current main passed Both individual merge previews are clean.
Combined PR heads failed Conflict is in the shared technical-debt file.
Other applicable hosted checks passed Conventions, labels, portability, report and eligibility passed; Linux workflow job was skipped.
Pairwise merge output
Auto-merging core/libs/prx/libSceNet/Export.cpp
Auto-merging core/libs/prx/libkernel/Socket/include/SocketPoll.hpp
Auto-merging core/libs/prx/libkernel/Socket/src/Udp.cpp
Auto-merging core/libs/tests/GuestSceNet.cpp
Auto-merging docs/dev/debt/libSceNet.md
CONFLICT (content): Merge conflict in docs/dev/debt/libSceNet.md

Negative control

I made no code mutation. The author reports that the regression test failed against the previous forwarding implementation; I did not independently repeat that control.

Findings

Blocking

  • #9948 remains open and both PRs change the same sceNetGetSockInfo technical-debt entry. The current heads conflict in that shared paragraph when combined, although each merges individually into current main. CONTRIBUTING.md requires authors with overlapping changes to agree which lands first and record the order. Please coordinate with #9948's author and update Depends on on whichever PR is second; preserve both sets of debt information when resolving the paragraph.

Non-blocking

None.

Sources

Not verified

I did not rerun the C++ tests locally; the Linux logs are author-provided, and the Windows result is hosted CI. Linux GitHub Actions, console behavior, and the negative control were not independently run by me.

To get this to a good state

Agree and record the landing order with #9948's author, then resolve the shared debt paragraph without losing either measurement. I will rerun the pairwise preview and review any changed head.

@XatiX

XatiX commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

@MarcZX10 This PR does not edit docs/dev/debt/libSceNet.md. Its only debt change is the libkernel hooks entry in docs/dev/debt/libkernel.md. The conflict you found is between #9948 and main, and it shows with or without this PR:

$ git diff --name-only a4eca2a056...7a4fa3865b
core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/include/SocketPoll.hpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestNetKernelForwards.cpp
docs/dev/debt/libkernel.md

$ git merge-tree --write-tree --name-only a4eca2a056 7a4fa3865b     # main + this PR
clean
$ git merge-tree --write-tree --name-only a4eca2a056 52566995bb     # main + #9948
CONFLICT (content): Merge conflict in docs/dev/debt/libSceNet.md
$ git merge-tree --write-tree --name-only 7a4fa3865b 52566995bb     # this PR + #9948
Auto-merging core/libs/prx/libSceNet/Export.cpp
Auto-merging core/libs/prx/libkernel/Socket/include/SocketPoll.hpp
Auto-merging core/libs/prx/libkernel/Socket/src/Udp.cpp
CONFLICT (content): Merge conflict in docs/dev/debt/libSceNet.md

The result is the same on today's main 096c45570f. The conflicting hunks are main's sceNetGetSockInfo bullets, rewritten when #9932 merged today, and its sceNetSetsockopt socket-level options bullet from #11968, against #9948's lines in the same place. oneandonlydean already raised that on #9948 this morning. The code files the two PRs share merge cleanly in both orders.

So neither PR needs the other first. #9948 has to be rebased on main whichever lands first, and its debt bullets resolved against main's. That doesn't touch this PR's files. Depends on: none stays on this PR. @ntamas94, for your side: nothing in this PR changes libSceNet.md, so landing it first or second makes no difference to your rebase.

The Linux logs you checked are unchanged; the head is still 7a4fa3865b.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 7a4fa38 merged onto main a4eca2a · tested 2026-11-02 20:00 UTC · 25 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 3,326 passed · 12 failed (0 new, 11 also fail on main, 1 unstable on main) · 58 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 3,396 of 3,591 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (1300 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.2 s, ⚠️ agc_driver_graphics 97.4 s, ⚠️ public_headers 83.9 s, ⚠️ agc_driver_bda_device 46.3 s, ⚠️ agc_driver_image_sample_unnormalized 45.6 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 4 of the last 6 main runs
Failing on main too (11, not counted against this PR)
agc_driver_guest_memory_lifetime_direct
agc_driver_image_table
agc_driver_job_manager_compute_capacity
agc_driver_native_depth_bda_clear
agc_driver_native_depth_buffer_clear
agc_driver_native_depth_clears
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_idle_publish_wait
agc_submit_progress
agc_submit_progress_no_timeline
Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)
guest_pthread_start: Timeout in the parallel run; also passed only on retry in 11 other runs in the last 7 days
Validated but not compared (1, not in the main baseline's validation pass)
guest_pthread_start
Validation IDs already present on main (4 IDs in 754 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (754 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, and 746 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (58)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_copied_writer_label_order_drain: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL 
Reproduce
git fetch origin 7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98 a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8
git checkout a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8 && git merge --no-ff 7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

XatiX pushed a commit to XatiX/AnyPS5 that referenced this pull request Nov 2, 2026
@B-Howell

B-Howell commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Tester run at head 7a4fa3865b, merged onto current main 9090972b7e (164 commits after the branch point bc12e15225). The merge is clean, and git diff --check is clean. Each arm ran --repeat until-fail:3 on Windows and on Linux. The control arm puts main's libSceNet/Export.cpp, libkernel/Socket/include/SocketPoll.hpp and libkernel/Socket/src/Udp.cpp back and keeps the PR's test and its registration. The reviews list a negative control as not independently run. The author's control was against the earlier forwarding code. This one is against main, which has no forwarding.

Setup. Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7. Linux: WSL2 Ubuntu 22.04 (kernel 6.18.33.2) with GCC 11.4.0, an older compiler than the 13.3 in the Linux logs above. Both builds are Ninja Release with BUILD_TESTING=ON. The regex was guest_sce_net|guest_net|net_epoll|guest_udp|guest_socket|guest_tcp|guest_datagram|socket|sockopt, which matches 63 tests on Windows and 52 on Linux.

Arm Windows Linux
main + PR 63/63 passed, x3 52/52 passed, x3
control (main's production files, PR test kept) 62/63 passed: guest_sce_net_kernel_forwards fails failed at line 53, errno 38 51/52 passed: same failure, same line and errno
  • Line 53 is the first bind_nid_postfix on the sceNetSocket socket in CheckDatagram, after the socket() pass has succeeded. So the new test catches the missing forwards on both platforms. Without any forwarding it stops at the first ordinary bind, before the null-bind check where the author's control failed.
  • On current main that call fails with ENOTSOCK (38), not EBADF. Since d5d1778, Lookup returns 38 for any open non-socket descriptor. The description's "failed with EBADF" could say ENOTSOCK.
  • Unrelated flake: in my first Windows pass on a busy machine, guest_net_ctl, guest_sce_net and net_epoll_lifetime_modify each failed once. A second full pass was clean.
    • guest_net_ctl also fails on the control, 4 of 20 runs at -j 3 with 12 busy-loop processes, each time with the same abort(). It is not from this PR.
    • The other two did not fail again in 38 more runs of the change (3 in the second full pass, 15 sequential, 20 under that load), or in 23 runs of the control.

Not tested: a title, connect/listen forwarding (not in this PR), macOS.

AI-assisted: yes (Claude Code)

@XairRrR XairRrR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — approved

libkernel's bind, getsockname, sendto and recvfrom now reach sceNetSocket descriptors and run libkernel's validation first. On Linux the new test passes, it fails against main's production files, and I found nothing blocking.

What I ran

Head 7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98, merged with --no-ff into main 9090972b7e91fd266819cbd77a8b058e177b5682 (merged tree 77ff4a4093ac88a49a1b492da9b5db0f961e3eea). Debian 13 VM, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.

git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98
python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "guest_sce_net|guest_net|net_epoll|guest_udp|guest_socket|guest_tcp|guest_datagram"
# negative control: restore main's libSceNet/Export.cpp, libkernel/Socket/include/SocketPoll.hpp, libkernel/Socket/src/Udp.cpp
ninja -C build guest_net_kernel_forwards_tests
ctest --test-dir build --output-on-failure -R "^guest_sce_net_kernel_forwards$"
# restore the merged files
ninja -C build guest_net_kernel_forwards_tests
ctest --test-dir build -R "^guest_sce_net_kernel_forwards$" --repeat until-fail:5
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure, build and libs (script) succeeded
Selected tests (script, 3366 run) 0 new failures, 0 timeouts. The 9 known failures also fail on main. guest_net_ctl is skipped on main too.
Focused network tests (51) 49 passed. guest_socket_options_multicast failed: it is on the known-failure list for main (the 224.0.0.251 join fails in this VM). guest_net_ctl was skipped, as on main.
guest_sce_net_kernel_forwards passed (0.21 s), and 5 of 5 under --repeat until-fail:5
Worktree after the control clean (git status --porcelain printed nothing)
Multicast failure (also fails on main)
1/51 Test #3241: guest_socket_options_multicast ....Subprocess aborted***Exception:   0.01 sec
joining 224.0.0.251 through INADDR_ANY failed (errno 5)

Negative control

I restored main's core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/include/SocketPoll.hpp and core/libs/prx/libkernel/Socket/src/Udp.cpp, kept the PR's test and its registration, and rebuilt. guest_sce_net_kernel_forwards then fails:

failed at line 53, errno 38

Line 53 is the first bind on the sceNetSocket socket. This matches what B-Howell reported on Windows and WSL2, now confirmed on a native Linux VM with GCC 14. After I restored the merged files and rebuilt, the test passed again.

Findings

Blocking

None.

Non-blocking

  • The shared-number debt now covers more calls. Where: docs/dev/debt/libkernel.md:205 and core/libs/prx/libkernel/Socket/src/Udp.cpp:278-282.
    • Why it matters: ForwardsFor forwards any descriptor that is not in libkernel's socket table and that libSceNet knows. The entry says a CRT file descriptor and a libSceNet socket can share a number, and that "close then closes the socket". With this PR, bind, getsockname, sendto and recvfrom on such a file descriptor also act on the socket instead of returning ENOTSOCK. getsockopt already did this (Udp.cpp:1341), so the risk itself is not new; only the entry's wording now understates it.
    • Suggested fix: name all the hooked calls in that sentence, not just close.
  • The description's errno is out of date. B-Howell already noted this; I confirm it. On current main the unforwarded call fails with ENOTSOCK (38), not EBADF, as the negative control above shows. The description could be updated.
  • Duplicated constant. KernelWaitAll = 0x40 in core/libs/prx/libSceNet/Export.cpp:947 repeats libkernel's GuestWaitAll value. This is minor and needs no action unless a shared header becomes available.

On the earlier blocking finding about overlap with #9948 and #11281: the PR does not change docs/dev/debt/libSceNet.md, and this tree merges cleanly into current main. I did not merge #9948 myself.

Not verified

  • Windows and macOS. I ran Linux only; the Windows results come from the author, B-Howell and hosted CI.
  • Console behaviour of the forwarded calls, and the PPSA06866 claim. No title was run.
  • Vulkan validation was not compared, because the change touches no AGC driver, shader recompiler or VideoOut file.

@oneandonlydean oneandonlydean self-assigned this Nov 3, 2026
@oneandonlydean
oneandonlydean merged commit a74a4c3 into boykopovar:main Nov 3, 2026
12 checks passed
@XatiX
XatiX deleted the fix/libkernel-net-socket-forwards branch November 12, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs libkernel prx unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants