feat(libSceRudp): answer flush, remote info and buffer status for unconnected contexts #13718

Merged
zaryabzip merged 1 commit from upstream-pr/13718 into main 2026-10-31 21:16:32 +00:00
zaryabzip commented 2026-10-31 02:30:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-31T02:30:55Z.


What

Three of the six libSceRudp exports in #13682 get bodies. They follow @BunnyFl's firmware 13.42 run of the real exports, done under an emulator with imports stubbed, not on a console.

Export Checks, in order Answer here
sceRudpFlush(int ctxId) not initialized 0x80770001; ctxId < 0 0x80770004; unknown or terminated id 0x80770003 0x80770011 (NOT_ACCEPTABLE)
sceRudpGetRemoteInfo(ctxId, addr, addrLen, vport) (declaration unchanged) the same three, with no checks on the outputs 0x80770011, outputs untouched
sceRudpGetContextBufferStatus(int ctxId, void* out, size_t size) not initialized; then ctxId < 0, null out or size outside 1 to 16 (a 64-bit compare) 0x80770004; unknown or terminated id writes size zero bytes, returns 0

No context here ever connects, because there is no reliable-UDP stack on the host. The run gave 0x80770011 for Flush and GetRemoteInfo on created, bound and listening contexts. GetContextBufferStatus wrote zeros for every context state it reached. The only other answers in the run came from connected states (internal states 4 and 5) that BunnyFl reached by writing the state field by hand, and nothing here can reach them. Flush and GetContextBufferStatus now take the arguments from the run instead of none.

Accept, Listen and GetLocalInfo stay throwing for now. They need sceRudpBind to keep the socket id, virtual port and mux mode, and the run shows main's Bind arguments are named and checked differently, so they belong with a Bind fix in a separate PR. The debt entry for these three cites the run and states that the connected states are unreachable. libSceRudp goes from 28 to 31 of 35.

The new GuestRudpUnconnected.cpp covers each check in order: before sceRudpInit, on unknown and negative ids, on a created context, after sceRudpTerminate and after sceRudpEnd. It also checks that the outputs stay untouched on every error. It resolves Flush and GetContextBufferStatus at runtime through function types that match the new declarations, because main declares them without parameters. So the test builds on main and aborts there at the first call.

Tested

Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 0e08e95853 merged into main d30e04fb8a.

  • No warnings. Every file that includes libSceRudp/include/Api.hpp rebuilds with no warnings, and so does each header compiled on its own.
  • ctest -R "guest_rudp|guest_offline_imports": 8 of 8 pass on both hosts, including the new guest_rudp_unconnected (Rudp unconnected tests passed). Each passes 3 of 3 on --repeat until-fail:3. rudp_poll_wait_exception (Windows only) also passes.
  • Baseline: on that main with only the new test file and its CMakeLists.txt block, the test builds and then aborts with sceRudpFlush not implemented on both hosts (Windows exit 0xc0000409, Linux SIGABRT).
  • tools/check_conventions.py passes, and tools/pr_overlap.py reports no overlap with open pull requests.

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: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5093673370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13718). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-10-31T02:30:55Z. --- ### What Three of the six libSceRudp exports in #13682 get bodies. They follow @BunnyFl's [firmware 13.42 run](https://github.com/boykopovar/AnyPS5/issues/13682#issuecomment-6537745577) of the real exports, done under an emulator with imports stubbed, not on a console. | Export | Checks, in order | Answer here | |---|---|---| | `sceRudpFlush(int ctxId)` | not initialized `0x80770001`; `ctxId < 0` `0x80770004`; unknown or terminated id `0x80770003` | `0x80770011` (`NOT_ACCEPTABLE`) | | `sceRudpGetRemoteInfo(ctxId, addr, addrLen, vport)` (declaration unchanged) | the same three, with no checks on the outputs | `0x80770011`, outputs untouched | | `sceRudpGetContextBufferStatus(int ctxId, void* out, size_t size)` | not initialized; then `ctxId < 0`, null `out` or `size` outside 1 to 16 (a 64-bit compare) `0x80770004`; unknown or terminated id | writes `size` zero bytes, returns 0 | No context here ever connects, because there is no reliable-UDP stack on the host. The run gave `0x80770011` for `Flush` and `GetRemoteInfo` on created, bound and listening contexts. `GetContextBufferStatus` wrote zeros for every context state it reached. The only other answers in the run came from connected states (internal states 4 and 5) that BunnyFl reached by writing the state field by hand, and nothing here can reach them. `Flush` and `GetContextBufferStatus` now take the arguments from the run instead of none. `Accept`, `Listen` and `GetLocalInfo` stay throwing for now. They need `sceRudpBind` to keep the socket id, virtual port and mux mode, and the run shows main's `Bind` arguments are named and checked differently, so they belong with a `Bind` fix in a separate PR. The debt entry for these three cites the run and states that the connected states are unreachable. libSceRudp goes from 28 to 31 of 35. The new `GuestRudpUnconnected.cpp` covers each check in order: before `sceRudpInit`, on unknown and negative ids, on a created context, after `sceRudpTerminate` and after `sceRudpEnd`. It also checks that the outputs stay untouched on every error. It resolves `Flush` and `GetContextBufferStatus` at runtime through function types that match the new declarations, because `main` declares them without parameters. So the test builds on `main` and aborts there at the first call. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1), both with the head 0e08e95853 merged into `main` d30e04fb8a. - No warnings. Every file that includes `libSceRudp/include/Api.hpp` rebuilds with no warnings, and so does each header compiled on its own. - `ctest -R "guest_rudp|guest_offline_imports"`: 8 of 8 pass on both hosts, including the new `guest_rudp_unconnected` (`Rudp unconnected tests passed`). Each passes 3 of 3 on `--repeat until-fail:3`. `rudp_poll_wait_exception` (Windows only) also passes. - Baseline: on that `main` with only the new test file and its `CMakeLists.txt` block, the test builds and then aborts with `sceRudpFlush not implemented` on both hosts (Windows exit 0xc0000409, Linux SIGABRT). - `tools/check_conventions.py` passes, and `tools/pr_overlap.py` reports no overlap with open pull requests. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-10-31 02:37:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T02:37:29Z.

Review: APPROVED


Reviewed — looks good

The exact-head implementation matches the reported unconnected-context results, and I found no blocking defect in the changed code.

What I ran

Reviewed head 0e08e9585348289b391457015c9382483758ea6d, based on current main 0cc02f7cde69941f651819b1f7a80f7aa722a08b; the merge preview was clean. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. I did not compile or run C++ tests locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13718
git diff 0cc02f7cde69941f651819b1f7a80f7aa722a08b...0e08e9585348289b391457015c9382483758ea6d --check
python3 tools/pr_abi_audit.py --base 0cc02f7cde69941f651819b1f7a80f7aa722a08b --head 0e08e9585348289b391457015c9382483758ea6d
python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13718-0e08e9585348/head-0e08e9585348-3d3990f0 --json core/libs/prx/libSceRudp/CMakeLists.txt core/libs/prx/libSceRudp/Export.cpp core/libs/prx/libSceRudp/include/Api.hpp core/libs/tests/GuestRudpUnconnected.cpp docs/dev/debt/libSceRudp.md
gh pr checks 13718 --repo boykopovar/AnyPS5

Results

Check Result
Diff and conventions Passed on the exact head.
Aggregate no-build precheck Diff, conventions, and current-main merge preview passed; exact head/base were unchanged at completion. The isolated checkout lacked workspace-only ABI/test-quality scripts, so I reran them from the workspace.
ABI audit Passed with no lexical findings. This is not a compiled ABI check.
Test registration The heuristic flagged a possible unregistered test; manual inspection confirmed add_test_executable and add_test(NAME guest_rudp_unconnected ...) are present.
Hosted CI Conventions, labels, eligibility, intake, library-portability, and report passed. The Windows job was in progress. Linux, relinker, ASAN, register-context, and write-watch jobs were skipped by workflow selection.
Focused tests The author reports guest_rudp_unconnected and related guest_rudp/guest_offline_imports tests passed 8/8 on Windows and Ubuntu/WSL2, each 3/3 under --repeat until-fail:3; Windows rudp_poll_wait_exception also passed. These are author-reported, not locally reproduced.
Unedited output from local checks

Convention check:

All conventions checks passed.

ABI audit:

ABI audit: passed
sceRudpFlush: NID=Ms0cLK8sTtE declarations=1 definitions=1 aliases=0
sceRudpGetContextBufferStatus: NID=KvNtKQLDgVk declarations=1 definitions=1 aliases=0
sceRudpGetRemoteInfo: NID=Qignjmfgha0 declarations=1 definitions=1 aliases=0
limit: This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.
limit: An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects.

The test-quality heuristic's output:

{
  "findings": [
    {
      "path": "core/libs/tests/GuestRudpUnconnected.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."
  ]
}

Negative control

Assertion Change to code under test Result
New tests distinguish this implementation from main Restore the throwing sceRudpFlush stub The author reports the test aborts on both hosts; I did not run this control.

Sources

Not verified

No local compilation or test execution, physical-console behavior, or real network connection. The firmware observations were made under an emulator with imports stubbed. Hosted Windows CI was still running; Linux and relinker-related jobs were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5720614690 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13718#pullrequestreview-5720614690). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T02:37:29Z. **Review:** APPROVED --- # Reviewed — looks good The exact-head implementation matches the reported unconnected-context results, and I found no blocking defect in the changed code. ## What I ran Reviewed head `0e08e9585348289b391457015c9382483758ea6d`, based on current `main` `0cc02f7cde69941f651819b1f7a80f7aa722a08b`; the merge preview was clean. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. I did not compile or run C++ tests locally. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13718 git diff 0cc02f7cde69941f651819b1f7a80f7aa722a08b...0e08e9585348289b391457015c9382483758ea6d --check python3 tools/pr_abi_audit.py --base 0cc02f7cde69941f651819b1f7a80f7aa722a08b --head 0e08e9585348289b391457015c9382483758ea6d python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13718-0e08e9585348/head-0e08e9585348-3d3990f0 --json core/libs/prx/libSceRudp/CMakeLists.txt core/libs/prx/libSceRudp/Export.cpp core/libs/prx/libSceRudp/include/Api.hpp core/libs/tests/GuestRudpUnconnected.cpp docs/dev/debt/libSceRudp.md gh pr checks 13718 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff and conventions | Passed on the exact head. | | Aggregate no-build precheck | Diff, conventions, and current-main merge preview passed; exact head/base were unchanged at completion. The isolated checkout lacked workspace-only ABI/test-quality scripts, so I reran them from the workspace. | | ABI audit | Passed with no lexical findings. This is not a compiled ABI check. | | Test registration | The heuristic flagged a possible unregistered test; manual inspection confirmed `add_test_executable` and `add_test(NAME guest_rudp_unconnected ...)` are present. | | Hosted CI | Conventions, labels, eligibility, intake, library-portability, and report passed. The Windows job was in progress. Linux, relinker, ASAN, register-context, and write-watch jobs were skipped by workflow selection. | | Focused tests | The author reports `guest_rudp_unconnected` and related `guest_rudp`/`guest_offline_imports` tests passed 8/8 on Windows and Ubuntu/WSL2, each 3/3 under `--repeat until-fail:3`; Windows `rudp_poll_wait_exception` also passed. These are author-reported, not locally reproduced. | <details> <summary>Unedited output from local checks</summary> Convention check: ```text All conventions checks passed. ``` ABI audit: ```text ABI audit: passed sceRudpFlush: NID=Ms0cLK8sTtE declarations=1 definitions=1 aliases=0 sceRudpGetContextBufferStatus: NID=KvNtKQLDgVk declarations=1 definitions=1 aliases=0 sceRudpGetRemoteInfo: NID=Qignjmfgha0 declarations=1 definitions=1 aliases=0 limit: This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation. limit: An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects. ``` The test-quality heuristic's output: ```json { "findings": [ { "path": "core/libs/tests/GuestRudpUnconnected.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." ] } ``` </details> ## Negative control | Assertion | Change to code under test | Result | |---|---|---| | New tests distinguish this implementation from `main` | Restore the throwing `sceRudpFlush` stub | The author reports the test aborts on both hosts; I did not run this control. | ## Sources - [Changed implementation at reviewed head `0e08e95`](https://github.com/boykopovar/AnyPS5/blob/0e08e9585348289b391457015c9382483758ea6d/core/libs/prx/libSceRudp/Export.cpp#L316-L331) and [flush implementation](https://github.com/boykopovar/AnyPS5/blob/0e08e9585348289b391457015c9382483758ea6d/core/libs/prx/libSceRudp/Export.cpp#L541-L552), [buffer-status implementation](https://github.com/boykopovar/AnyPS5/blob/0e08e9585348289b391457015c9382483758ea6d/core/libs/prx/libSceRudp/Export.cpp#L607-L619) - [Regression assertions at reviewed head](https://github.com/boykopovar/AnyPS5/blob/0e08e9585348289b391457015c9382483758ea6d/core/libs/tests/GuestRudpUnconnected.cpp#L77-L100) - [Author-provided firmware 13.42 emulator observations](https://github.com/boykopovar/AnyPS5/issues/13682#issuecomment-6537745577) ## Not verified No local compilation or test execution, physical-console behavior, or real network connection. The firmware observations were made under an emulator with imports stubbed. Hosted Windows CI was still running; Linux and relinker-related jobs were skipped.
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!13718
No description provided.