fix(libSceRudp): cancel and drain poll waiters on destroy and end #13814
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13814"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-31T07:44:08Z.
What
sceRudpPollDestroyandsceRudpEndnow treat waiters as @BunnyFl's firmware 13.42 run of the module shows. That run was under an emulator with imports stubbed, not on a console.mainsceRudpPollDestroy(pollId)0x80770014(CANCELLED), every waiter of the poll0x8077001FsceRudpEnd()0x80770014, every waiter of every poll (the run had one waiter)0x80770001The debt entry for these two already recorded the difference.
sceRudpPollCancelalready drains this way (#11294), so the change follows its pattern: a destroyed or ended poll's waiters are counted until they leave, and the call waits for that count to reach zero. What happens afterwards is unchanged and matches the run: a wait on the destroyed id returns0x8077001F, and aftersceRudpEndwaits and cancels return0x80770001.Unmeasured, and recorded in the rewritten debt entry: calls on a poll while
sceRudpPollDestroydrains it (here they already answer as for a destroyed poll),sceRudpInitwhilesceRudpEnddrains, and real-kernel wake and timeout races. No function changes count.The new
GuestRudpPollDrain.cppchecks both calls from waiters that signal before they wait. Each round starts waiters (two on one poll for destroy, one for end, as in the run), then callssceRudpPollDestroyorsceRudpEnd. A round where a waiter arrived after the call is skipped; it shows up as0x8077001For0x80770001. The test requires the waiters to return0x80770014and to be back by the time the call returns, over up to 20 rounds.GuestRudpPoll.cpploses its sleep-based waiter checks for destroy and end, and checks instead that a wait after them returns0x8077001For0x80770001.sceRudpEndrecords its waiters before it marks the library uninitialized, so an allocation failure leaves nothing half done.Overlap:
tools/pr_overlap.pyfinds conflicts only with my own #13718 (the next debt line) and #13799 (sceRudpEndand the next debt lines). This one doesn't depend on them, and I'll rebase whichever merges later.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
05ffd4d30amerged intomaine8c25dd3ba.Export.cpp,GuestRudpPoll.cpporGuestRudpPollDrain.cpp.ctest -R "guest_rudp|rudp_poll" --timeout 120: 7 of 7 pass on WSL2 and 8 of 8 on Windows (plusrudp_poll_wait_exception).guest_rudp_poll_drainandguest_rudp_polleach pass 10 of 10 on--repeat until-fail:10; the drain test takes about 0.05 s on WSL2 and 0.1 s on Windows.guest_rudp_poll_drainfailed 10 of 10 runs on both hosts withsceRudpPollDestroy returned before its waiters had left the wait. With onlysceRudpEnd's deleted, it failed 10 of 10 on both withsceRudpEnd returned before its waiter had left the wait.mainwith onlyGuestRudpPollDrain.cppand itsCMakeLists.txtblock, the test builds and then aborts withno waiter woken by sceRudpPollDestroy returned 0x80770014on both hosts (Windows exit 0xc0000409, Linux SIGABRT).tools/check_conventions.pypasses;tools/pr_overlap.pyis described above.Rerun after the
mainmerge, by me, atd6cfab2265, which containsmain10163b0973(comment):ctest -R "^guest_rudp"passes all 9 tests on Windows 11 Home 25H2 (WinLibs GCC 15.2.0 r7, Release) and on WSL2 (GCC 13.3.0, Release).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T07:50:37Z.
Review: APPROVED
Reviewed — looks good
I reviewed head
43f978e556f4bb13c4aa25b51e522720c03c7307; the wait-drain logic matches the reported firmware behavior, and the exact-head test evidence is strong.What I ran
Head
43f978e556f4bb13c4aa25b51e522720c03c7307; PR base828ac0b2ae74aac181ba128fb59b08a1534f2041; the current-base merge preview was clean. Environment: Linux x86_64, kernel 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. I did not build or run C++ tests locally.Results
828ac0b2ae74aac181ba128fb59b08a1534f2041; no declared dependencies.guest_rudp_pollfromGuestRudpPoll.cpp.Unedited output from local checks
The CMake registration inspected at this head is
add_test(NAME guest_rudp_poll COMMAND guest_rudp_poll_tests).git diff --checkemitted no output and exited successfully.Negative control
CANCELLEDwhen their poll is destroyed828ac0b2ae74aac181ba128fb59b08a1534f2041with the test file addedFindings
Blocking
None found in the reviewed source and evidence.
Non-blocking
The PR documents concurrent
sceRudpInitduringsceRudpEnddraining and real-kernel wake/timeout races as unmeasured. The submitted change does not claim those cases were measured; they remain recorded in the library debt entry.Sources
Not verified
I did not build or run C++ tests locally, reproduce the author’s Windows/WSL2 tests or negative control, test real-kernel races, or test on console hardware. Hosted Windows CI was still running at the final status check; Linux and specialized jobs were skipped.