feat(libSceRudp): implement sceRudpPollCancel as firmware 13.42's library does #11294

Merged
harisibrar1 merged 6 commits from upstream-pr/11294 into main 2026-10-28 09:25:11 +00:00
harisibrar1 commented 2026-10-26 00:39:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-26T00:39:31Z.


What

sceRudpPollCancel is a parameterless placeholder that throws. This implements it as firmware 13.42's libSceRudp.sprx behaves in @BunnyFl's runs on #10954: the detailed report (module hash, export offsets, raw output of two identical runs) and the drain clarification. Those runs execute the real library with its kernel and libc imports stubbed and waits scheduled by a script. They are firmware-library execution, not a console measurement, and the debt entry says so. @AZLisme agreed in #10954 that I take sceRudpPollCancel, crediting @BunnyFl.

int sceRudpPollCancel(int pollId), the Orbital prototype, which the trace confirms (only the low 32 bits are read, the result is an int):

  • Before sceRudpInit: 0x80770001. Negative id: 0x80770004. Unknown or destroyed id: 0x8077001F.
  • No call waiting on the poll: the cancel is kept for that poll and returns 0. Two cancels still keep one. The next sceRudpPollWait on that poll returns 0x80770014 at once, also with a zero timeout, and the wait after it is normal again. Other polls are unaffected.
  • Calls waiting on the poll: all of them are woken and return 0x80770014. The cancel returns 0 once none is left inside the wait, and nothing stays pending.

In Export.cpp, each RudpPoll gains a waiter count, a draining count, a cancel generation and a pending flag.

  • sceRudpPollWait consumes a pending cancel before waiting. Otherwise it registers as a waiter and returns 0x80770014 when the generation changed while it waited. It looks the poll up by id again after every wake-up, so a poll destroyed during the wait is never touched through a stale reference.
  • A scope guard releases the registration on every exit, including an exception from the condition wait (retaking the lock if needed), following @thepoppfish's repair.
  • sceRudpPollCancel bumps the generation and moves the waits registered at that moment to the draining count. It then wakes everyone and waits until the draining count is 0, the poll is gone or the library has ended. A wait that starts during the drain is neither cancelled nor counted; that case is unmeasured on the console and the debt entry says so.

Not changed: on 13.42, sceRudpPollDestroy and sceRudpEnd also wake waiters with 0x80770014 and wait for them to leave. Here they still return at once and wake waiters with 0x8077001F/0x80770001, as #10954 records. That's a separate change.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, full Release build of e31fad5ae8 (current main merged in): no failed steps.

  • GuestRudpPoll.cpp gains: cancel before init; negative, INT_MIN and unknown ids; two idle cancels leaving one, consumed by the next wait, also by wait(0), with another poll unaffected; two waiters (infinite and 10 s) both returning 0x80770014, the cancel returning within 500 ms, and a later wait timing out normally; cancel on a destroyed poll; cancel after sceRudpEnd.
  • 40 late-arrival rounds: a cancel and a second infinite wait start together while an earlier wait is registered, and the cancel must return within 2 s.
  • New Windows-only rudp_poll_wait_exception. It compiles the production Export.cpp and TimedWait.cpp with an operator new that fails on one thread. After a wait throws inside TimedWait, a cancel must return at once and keep its pending cancellation.
  • All 7 guest_rudp*/rudp_poll_wait_exception tests pass, 5 runs. With the pre-fix Export.cpp (0c85096011), rudp_poll_wait_exception fails (2 of 2) and guest_rudp_poll fails at the late-arrival check (5 of 5).
  • Negative control: with main's Export.cpp (only the placeholder's signature changed so the test links), guest_rudp_poll aborts with "sceRudpPollCancel not implemented".
  • tools/check_conventions.py --base origin/main passes.
  • Not tested: Linux and macOS, or a console. A real kernel's race between a cancel and a timeout is untested; the trace couldn't cover it either.

Overlap

  • #10954 (@AZLisme) landed first as agreed. main is merged in, and its cancel/destroy/end debt entry now covers destroy and end only, with its gaps kept; PollCancel has its own entry.
  • #10993 (@EagleBearerYS) gives sceRudpSetMaxSegmentSize its parameter on the next line of include/Api.hpp and edits the same debt line, so git reports a conflict there. Both are text merges that keep both changes; it doesn't touch the poll code. Whichever lands second takes them.

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 (#10954 has landed and main is merged in)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5010275302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11294). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-26T00:39:31Z. --- ### What `sceRudpPollCancel` is a parameterless placeholder that throws. This implements it as firmware 13.42's `libSceRudp.sprx` behaves in @BunnyFl's runs on #10954: the [detailed report](https://github.com/boykopovar/AnyPS5/pull/10954#issuecomment-6399054346) (module hash, export offsets, raw output of two identical runs) and the [drain clarification](https://github.com/boykopovar/AnyPS5/pull/10954#issuecomment-6400073284). Those runs execute the real library with its kernel and libc imports stubbed and waits scheduled by a script. They are firmware-library execution, not a console measurement, and the debt entry says so. @AZLisme agreed in [#10954](https://github.com/boykopovar/AnyPS5/pull/10954#issuecomment-6399603313) that I take `sceRudpPollCancel`, crediting @BunnyFl. `int sceRudpPollCancel(int pollId)`, the [Orbital](https://github.com/AlexAltea/orbital/blob/b321fcdbd700cc02da1cb1ad25412781d5ec73c6/tools/ida/db_types.json) prototype, which the trace confirms (only the low 32 bits are read, the result is an int): - Before `sceRudpInit`: `0x80770001`. Negative id: `0x80770004`. Unknown or destroyed id: `0x8077001F`. - No call waiting on the poll: the cancel is kept for that poll and returns 0. Two cancels still keep one. The next `sceRudpPollWait` on that poll returns `0x80770014` at once, also with a zero timeout, and the wait after it is normal again. Other polls are unaffected. - Calls waiting on the poll: all of them are woken and return `0x80770014`. The cancel returns 0 once none is left inside the wait, and nothing stays pending. In `Export.cpp`, each `RudpPoll` gains a waiter count, a draining count, a cancel generation and a pending flag. - `sceRudpPollWait` consumes a pending cancel before waiting. Otherwise it registers as a waiter and returns `0x80770014` when the generation changed while it waited. It looks the poll up by id again after every wake-up, so a poll destroyed during the wait is never touched through a stale reference. - A scope guard releases the registration on every exit, including an exception from the condition wait (retaking the lock if needed), following @thepoppfish's repair. - `sceRudpPollCancel` bumps the generation and moves the waits registered at that moment to the draining count. It then wakes everyone and waits until the draining count is 0, the poll is gone or the library has ended. A wait that starts during the drain is neither cancelled nor counted; that case is unmeasured on the console and the debt entry says so. Not changed: on 13.42, `sceRudpPollDestroy` and `sceRudpEnd` also wake waiters with `0x80770014` and wait for them to leave. Here they still return at once and wake waiters with `0x8077001F`/`0x80770001`, as #10954 records. That's a separate change. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, full Release build of e31fad5ae8 (current `main` merged in): no failed steps. - `GuestRudpPoll.cpp` gains: cancel before init; negative, `INT_MIN` and unknown ids; two idle cancels leaving one, consumed by the next wait, also by `wait(0)`, with another poll unaffected; two waiters (infinite and 10 s) both returning `0x80770014`, the cancel returning within 500 ms, and a later wait timing out normally; cancel on a destroyed poll; cancel after `sceRudpEnd`. - 40 late-arrival rounds: a cancel and a second infinite wait start together while an earlier wait is registered, and the cancel must return within 2 s. - New Windows-only `rudp_poll_wait_exception`. It compiles the production `Export.cpp` and `TimedWait.cpp` with an `operator new` that fails on one thread. After a wait throws inside `TimedWait`, a cancel must return at once and keep its pending cancellation. - All 7 `guest_rudp*`/`rudp_poll_wait_exception` tests pass, 5 runs. With the pre-fix `Export.cpp` (`0c85096011`), `rudp_poll_wait_exception` fails (2 of 2) and `guest_rudp_poll` fails at the late-arrival check (5 of 5). - Negative control: with main's `Export.cpp` (only the placeholder's signature changed so the test links), `guest_rudp_poll` aborts with "sceRudpPollCancel not implemented". - `tools/check_conventions.py --base origin/main` passes. - Not tested: Linux and macOS, or a console. A real kernel's race between a cancel and a timeout is untested; the trace couldn't cover it either. ### Overlap - #10954 (@AZLisme) landed first as agreed. `main` is merged in, and its cancel/destroy/end debt entry now covers destroy and end only, with its gaps kept; PollCancel has its own entry. - #10993 (@EagleBearerYS) gives `sceRudpSetMaxSegmentSize` its parameter on the next line of `include/Api.hpp` and edits the same debt line, so git reports a conflict there. Both are text merges that keep both changes; it doesn't touch the poll code. Whichever lands second takes them. ### 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: none (#10954 has landed and `main` is merged in) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-26 00:42:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:42:00Z.

Review: DISMISSED


The waiter-drain can be held open indefinitely by a wait that starts after cancellation begins. sceRudpPollCancel increments poll.cancels, broadcasts, and waits until poll.waiters == 0. If a new sceRudpPollWait acquires the mutex before the original waiter(s) have drained, it snapshots the already-incremented generation and blocks normally; it is not woken by this cancellation. The original waiter decrements the count, but the new infinite waiter keeps it nonzero, so sceRudpPollCancel cannot return until that unrelated wait times out or some later operation destroys the poll. This is possible with concurrent poll users and can turn cancellation into an indefinite hang.

The added two-waiter test starts both waits before calling cancel, so it does not exercise this interleaving. Please make the drain/wakeup semantics robust for waiters arriving while cancellation is in progress, and add a bounded regression for that ordering. The firmware report establishes behavior for waiters already blocked when cancel is called, but does not settle arrivals during the drain; please keep that boundary explicit if the exact console behavior remains unknown.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5646216037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11294#pullrequestreview-5646216037). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T00:42:00Z. **Review:** DISMISSED --- The waiter-drain can be held open indefinitely by a wait that starts after cancellation begins. `sceRudpPollCancel` increments `poll.cancels`, broadcasts, and waits until `poll.waiters == 0`. If a new `sceRudpPollWait` acquires the mutex before the original waiter(s) have drained, it snapshots the already-incremented generation and blocks normally; it is not woken by this cancellation. The original waiter decrements the count, but the new infinite waiter keeps it nonzero, so `sceRudpPollCancel` cannot return until that unrelated wait times out or some later operation destroys the poll. This is possible with concurrent poll users and can turn cancellation into an indefinite hang. The added two-waiter test starts both waits before calling cancel, so it does not exercise this interleaving. Please make the drain/wakeup semantics robust for waiters arriving while cancellation is in progress, and add a bounded regression for that ordering. The firmware report establishes behavior for waiters already blocked when cancel is called, but does not settle arrivals during the drain; please keep that boundary explicit if the exact console behavior remains unknown.
thepoppfish commented 2026-10-26 01:04:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-26T01:04:09Z.

Review: DISMISSED


I found a separate exception-cleanup hang on exact head 344acf3e661e8b1a240f2cd0436df76d3c31c9b8, in addition to Marc's late-arrival finding.

sceRudpPollWait increments the poll's waiter count before entering TimedWait::Condition, but decrements it only on the normal path. On Windows, first-use wait state allocates real C++ objects. If that allocation throws, the call exits while its registration remains. A subsequent sceRudpPollCancel sees a waiter that can never drain.

I reproduced this with the complete production Export.cpp and TimedWait.cpp, actual Windows waits and thread-local state, and thread-scoped operator new faults. Four cases cover finite/infinite waits and the 80-byte waiter / 16-byte thread-state allocations. All four catch bad_alloc and leave cancel blocked past the 200 ms observation window. Destroying the poll releases the cancel thread, so the regression itself finishes normally. The 16-byte failure occurs after Condition::Wait has unlocked the mutex: cleanup must reacquire it before touching the poll map.

Tested repair: 57ee4b745ff7, on branch codex/review-rudp-wait-cleanup. One commit, three files, 140 insertions / 2 deletions. Its parent is a clean integration of this exact head and main 5b85225ef39b9321d8f5c251ecb391b8331e8aea; both histories are retained. The scope registration releases the count and notifies drain waiters on every exit, reacquiring the lock when necessary. It preserves the existing exception rather than inventing an SDK error result. The commit also registers the Windows native allocation regression.

Fresh Windows 11 build 26200 / GCC 16.2.0-6 UCRT64 / CMake 4.3.1 / Ninja 1.13.2 / Python 3.14.7 results:

  • Exact PR head: the allocation test fails all 4 cases (26 checks / 4 failures); all five complete existing RUDP fixtures pass.
  • Committed repair sources with their own headers: 6/6 isolated CTests pass, 0.93 s total, zero skips. Allocation regression: 4 cases / 34 checks / 0 failures; cancels return before cleanup and retain the single pending cancellation, which the next wait consumes.
  • Replayed the new CMake target with the repository's original test-executable/unwind helpers, WindowsTestExit.cpp and SEH personality object: 1/1 passes, 0.15 s total, zero skips. This uses the actual committed regression file and production sources. It is an isolated registration check, not a full product configure/build.
  • Conventions against origin/main (the pinned main above), whitespace and the public-header audit pass (368 libraries, 12,223 exports). No new public export declarations are introduced.

The isolated fixture's sole library adapter is NotImplemented_nid_no_patch throwing runtime_error for the existing unsupported-option tests. RUDP and TimedWait bodies are complete; neither waits nor the faulted allocations are replaced by fake implementations. The test keeps the failed wait's worker thread alive until cleanup, so its native wait-state object remains valid while checking the broken head.

This repair covers exception cleanup. Marc's separate cancellation/late-arrival finding remains unresolved, and the linked 13.42 library report does not establish that arrival policy. No console/title, full product/DLL runtime, Linux/macOS runtime, performance or hosted-CI result is claimed. AI-assisted: yes.

Isolated native replay

Check out this PR head as before and the support commit as after. Save the CMake file below and Support.cpp in a fixture directory. Copy after/core/libs/tests/RudpPollWaitAllocation.cpp to that directory as FaultTest.cpp. With the GCC/CMake/Ninja binaries on PATH and APS5_COARSE_TIMED_WAITS unset:

cmake -S fixture -B build-before -G Ninja -DCMAKE_BUILD_TYPE=Release -DREPO=<absolute-before>
cmake --build build-before -j 3
ctest --test-dir build-before --output-on-failure
cmake -S fixture -B build-after -G Ninja -DCMAKE_BUILD_TYPE=Release -DREPO=<absolute-after>
cmake --build build-after -j 3
ctest --test-dir build-after --output-on-failure

The before run should fail only rudp_wait_allocation_cleanup; the after run should pass all six. The production regression returns skip code 77 if coarse waits are explicitly enabled.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)
project(RudpWaitCleanupReview LANGUAGES CXX)
enable_testing()
get_filename_component(DEFAULT_REPO "../review-11294" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(REPO "${DEFAULT_REPO}" CACHE PATH "Source tree")
set(PRODUCTION_SOURCE "${REPO}/core/libs/prx/libSceRudp/Export.cpp" CACHE FILEPATH "Exact production source")
add_library(rudp_actual STATIC "${PRODUCTION_SOURCE}" "${REPO}/core/libs/prx/libkernel/Time/TimedWait.cpp")
target_include_directories(rudp_actual PUBLIC "${REPO}/core/libs")
target_compile_features(rudp_actual PUBLIC cxx_std_20)
target_compile_options(rudp_actual PUBLIC -O1 -g -fno-inline -fno-lto -ffunction-sections -fdata-sections)
target_link_options(rudp_actual PUBLIC -static-libgcc -static-libstdc++ -Wl,--gc-sections)
add_executable(fault_probe FaultTest.cpp)
target_link_libraries(fault_probe PRIVATE rudp_actual)
add_test(NAME rudp_wait_allocation_cleanup COMMAND fault_probe)
set_tests_properties(rudp_wait_allocation_cleanup PROPERTIES TIMEOUT 10 SKIP_RETURN_CODE 77)
foreach(name IN ITEMS Status Pump ContextQueries ContextLifecycle Poll)
    add_executable(author_${name} "${REPO}/core/libs/tests/GuestRudp${name}.cpp" Support.cpp)
    target_link_libraries(author_${name} PRIVATE rudp_actual)
    add_test(NAME author_${name} COMMAND author_${name})
    set_tests_properties(author_${name} PROPERTIES TIMEOUT 10)
endforeach()
foreach(target IN ITEMS fault_probe author_Status author_Pump author_ContextQueries author_ContextLifecycle author_Poll)
    add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_OBJCOPY}"
        --rename-section .eh_frame=.ehfram --rename-section .eh_fram=.ehfram "$<TARGET_FILE:${target}>" VERBATIM)
endforeach()

Support.cpp:

#include "prx/libc/include/General.hpp"
#include <stdexcept>
extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* name) { throw std::runtime_error(name); }
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5646319727 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11294#pullrequestreview-5646319727). Originally posted by [thepoppfish](https://github.com/thepoppfish) on 2026-10-26T01:04:09Z. **Review:** DISMISSED --- I found a separate exception-cleanup hang on exact head `344acf3e661e8b1a240f2cd0436df76d3c31c9b8`, in addition to Marc's late-arrival finding. `sceRudpPollWait` increments the poll's waiter count before entering `TimedWait::Condition`, but decrements it only on the normal path. On Windows, first-use wait state allocates real C++ objects. If that allocation throws, the call exits while its registration remains. A subsequent `sceRudpPollCancel` sees a waiter that can never drain. I reproduced this with the complete production `Export.cpp` and `TimedWait.cpp`, actual Windows waits and thread-local state, and thread-scoped `operator new` faults. Four cases cover finite/infinite waits and the 80-byte waiter / 16-byte thread-state allocations. All four catch `bad_alloc` and leave cancel blocked past the 200 ms observation window. Destroying the poll releases the cancel thread, so the regression itself finishes normally. The 16-byte failure occurs after `Condition::Wait` has unlocked the mutex: cleanup must reacquire it before touching the poll map. Tested repair: [57ee4b745ff7](https://github.com/thepoppfish/AnyPS5/commit/57ee4b745ff794ba03b66bf9e4e90830ce0130fa), on branch [codex/review-rudp-wait-cleanup](https://github.com/thepoppfish/AnyPS5/tree/codex/review-rudp-wait-cleanup). One commit, three files, 140 insertions / 2 deletions. Its parent is a clean integration of this exact head and main `5b85225ef39b9321d8f5c251ecb391b8331e8aea`; both histories are retained. The scope registration releases the count and notifies drain waiters on every exit, reacquiring the lock when necessary. It preserves the existing exception rather than inventing an SDK error result. The commit also registers the Windows native allocation regression. Fresh Windows 11 build 26200 / GCC 16.2.0-6 UCRT64 / CMake 4.3.1 / Ninja 1.13.2 / Python 3.14.7 results: - Exact PR head: the allocation test fails all **4 cases** (26 checks / 4 failures); all **five complete existing RUDP fixtures pass**. - Committed repair sources with their own headers: **6/6 isolated CTests pass**, 0.93 s total, zero skips. Allocation regression: **4 cases / 34 checks / 0 failures**; cancels return before cleanup and retain the single pending cancellation, which the next wait consumes. - Replayed the new CMake target with the repository's original test-executable/unwind helpers, `WindowsTestExit.cpp` and SEH personality object: **1/1 passes**, 0.15 s total, zero skips. This uses the actual committed regression file and production sources. It is an isolated registration check, not a full product configure/build. - Conventions against `origin/main` (the pinned main above), whitespace and the public-header audit pass (368 libraries, 12,223 exports). No new public export declarations are introduced. The isolated fixture's sole library adapter is `NotImplemented_nid_no_patch` throwing `runtime_error` for the existing unsupported-option tests. RUDP and TimedWait bodies are complete; neither waits nor the faulted allocations are replaced by fake implementations. The test keeps the failed wait's worker thread alive until cleanup, so its native wait-state object remains valid while checking the broken head. This repair covers exception cleanup. Marc's separate cancellation/late-arrival finding remains unresolved, and the linked 13.42 library report does not establish that arrival policy. No console/title, full product/DLL runtime, Linux/macOS runtime, performance or hosted-CI result is claimed. AI-assisted: yes. <details><summary>Isolated native replay</summary> Check out this PR head as `before` and the support commit as `after`. Save the CMake file below and `Support.cpp` in a fixture directory. Copy `after/core/libs/tests/RudpPollWaitAllocation.cpp` to that directory as `FaultTest.cpp`. With the GCC/CMake/Ninja binaries on PATH and `APS5_COARSE_TIMED_WAITS` unset: ```powershell cmake -S fixture -B build-before -G Ninja -DCMAKE_BUILD_TYPE=Release -DREPO=<absolute-before> cmake --build build-before -j 3 ctest --test-dir build-before --output-on-failure cmake -S fixture -B build-after -G Ninja -DCMAKE_BUILD_TYPE=Release -DREPO=<absolute-after> cmake --build build-after -j 3 ctest --test-dir build-after --output-on-failure ``` The before run should fail only `rudp_wait_allocation_cleanup`; the after run should pass all six. The production regression returns skip code 77 if coarse waits are explicitly enabled. `CMakeLists.txt`: ```cmake cmake_minimum_required(VERSION 3.20) project(RudpWaitCleanupReview LANGUAGES CXX) enable_testing() get_filename_component(DEFAULT_REPO "../review-11294" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}") set(REPO "${DEFAULT_REPO}" CACHE PATH "Source tree") set(PRODUCTION_SOURCE "${REPO}/core/libs/prx/libSceRudp/Export.cpp" CACHE FILEPATH "Exact production source") add_library(rudp_actual STATIC "${PRODUCTION_SOURCE}" "${REPO}/core/libs/prx/libkernel/Time/TimedWait.cpp") target_include_directories(rudp_actual PUBLIC "${REPO}/core/libs") target_compile_features(rudp_actual PUBLIC cxx_std_20) target_compile_options(rudp_actual PUBLIC -O1 -g -fno-inline -fno-lto -ffunction-sections -fdata-sections) target_link_options(rudp_actual PUBLIC -static-libgcc -static-libstdc++ -Wl,--gc-sections) add_executable(fault_probe FaultTest.cpp) target_link_libraries(fault_probe PRIVATE rudp_actual) add_test(NAME rudp_wait_allocation_cleanup COMMAND fault_probe) set_tests_properties(rudp_wait_allocation_cleanup PROPERTIES TIMEOUT 10 SKIP_RETURN_CODE 77) foreach(name IN ITEMS Status Pump ContextQueries ContextLifecycle Poll) add_executable(author_${name} "${REPO}/core/libs/tests/GuestRudp${name}.cpp" Support.cpp) target_link_libraries(author_${name} PRIVATE rudp_actual) add_test(NAME author_${name} COMMAND author_${name}) set_tests_properties(author_${name} PROPERTIES TIMEOUT 10) endforeach() foreach(target IN ITEMS fault_probe author_Status author_Pump author_ContextQueries author_ContextLifecycle author_Poll) add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_OBJCOPY}" --rename-section .eh_frame=.ehfram --rename-section .eh_fram=.ehfram "$<TARGET_FILE:${target}>" VERBATIM) endforeach() ``` `Support.cpp`: ```cpp #include "prx/libc/include/General.hpp" #include <stdexcept> extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* name) { throw std::runtime_error(name); } ``` </details>
jotitadev commented 2026-10-27 01:06:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T01:06:59Z.

Review: COMMENTED


Linux run of the current head, since the description says Linux was not tested.

Machine: Linux x86_64, i7-8700 (6 cores / 12 threads, AVX2), Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON. Head 4fe05b3be merged onto main cb45ae2dd.

  • Build ok. All 6 guest_rudp* tests pass, including #10954's guest_rudp_empty_poll.
  • guest_rudp_poll relies on a 100 ms sleep before the cancel and a 500 ms bound on it, so I ran it repeatedly: 200 of 200 sequential runs, and 300 of 300 with 12 copies at a time on a loaded machine (25 rounds). No hang and no failed timing check.
  • Replacing only sceRudpPollCancel's body with NotImplemented_nid_no_patch and keeping the test aborts with sceRudpPollCancel not implemented.

This does not cover the late-arrival and exception-cleanup cases raised above; the test does not exercise them.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661087116 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11294#pullrequestreview-5661087116). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T01:06:59Z. **Review:** COMMENTED --- Linux run of the current head, since the description says Linux was not tested. Machine: Linux x86_64, i7-8700 (6 cores / 12 threads, AVX2), Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `4fe05b3be` merged onto `main` `cb45ae2dd`. - Build ok. All 6 `guest_rudp*` tests pass, including #10954's `guest_rudp_empty_poll`. - `guest_rudp_poll` relies on a 100 ms sleep before the cancel and a 500 ms bound on it, so I ran it repeatedly: 200 of 200 sequential runs, and 300 of 300 with 12 copies at a time on a loaded machine (25 rounds). No hang and no failed timing check. - Replacing only `sceRudpPollCancel`'s body with `NotImplemented_nid_no_patch` and keeping the test aborts with `sceRudpPollCancel not implemented`. This does not cover the late-arrival and exception-cleanup cases raised above; the test does not exercise them. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
adriadam10 commented 2026-10-27 08:15:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T08:15:45Z.

Review: CHANGES_REQUESTED


Two real problems in sceRudpPollWait/sceRudpPollCancel remain on this head (both also raised by @MarcZX10 and @thepoppfish):

  • Export.cpp:538-544: Cancel drains until poll.waiters == 0, but a sceRudpPollWait that arrives after the cancel starts snapshots the already-incremented cancels (Export.cpp:458), blocks normally and keeps waiters above 0, so Cancel can be held until that unrelated wait ends (forever for an infinite one). Cancel should only wait for the waiters that were inside the wait when it ran, e.g. give each wait a ticket and drain until no active ticket at or below the cancel's cutoff is left; late arrivals must not count.
  • Export.cpp:459-482: ++waiters is undone only on the normal return. If TimedWait throws (first-use wait state allocation on Windows), the registration stays and every later Cancel on that poll never drains. Undo the registration on every exit path (a scope guard that re-finds the poll under the lock).

Please add a test for each (a wait started after Cancel began must not extend it). The rest checked out: prototype and error values match the cited #10954 report, the debt entries split cleanly, and the new test fails on main (placeholder throws). Happy to look again once these are in.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5663936415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11294#pullrequestreview-5663936415). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-27T08:15:45Z. **Review:** CHANGES_REQUESTED --- Two real problems in `sceRudpPollWait`/`sceRudpPollCancel` remain on this head (both also raised by @MarcZX10 and @thepoppfish): - `Export.cpp:538-544`: Cancel drains until `poll.waiters == 0`, but a `sceRudpPollWait` that arrives after the cancel starts snapshots the already-incremented `cancels` (`Export.cpp:458`), blocks normally and keeps `waiters` above 0, so Cancel can be held until that unrelated wait ends (forever for an infinite one). Cancel should only wait for the waiters that were inside the wait when it ran, e.g. give each wait a ticket and drain until no active ticket at or below the cancel's cutoff is left; late arrivals must not count. - `Export.cpp:459-482`: `++waiters` is undone only on the normal return. If `TimedWait` throws (first-use wait state allocation on Windows), the registration stays and every later Cancel on that poll never drains. Undo the registration on every exit path (a scope guard that re-finds the poll under the lock). Please add a test for each (a wait started after Cancel began must not extend it). The rest checked out: prototype and error values match the cited #10954 report, the debt entries split cleanly, and the new test fails on main (placeholder throws). Happy to look again once these are in.
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!11294
No description provided.