fix(libSceNpAuth): reject completion queries before request start #8611

Merged
Ondra97 merged 1 commit from upstream-pr/8611 into main 2026-10-22 19:54:21 +00:00
Ondra97 commented 2026-10-20 18:23:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-20T18:23:37Z.


What

An async request aborted before start is accepted by Poll/Wait as if it had been submitted: Poll reports running and then finishes with SIGNED_OUT. Calling a getter in between changes that completion to ABORTED, even though the getter rejects the start.

Poll/Wait now require a started async request, and rejected getters leave the stored result alone. The getters still return ABORTED. This follows the request model already referenced by the library: shadPS4's StartRequest rejects a pre-start abort without creating a context, and FindAsyncRequest requires that context for Poll/Wait.

The regression covers sync/async requests, repeated aborts and queries, the legacy/V3 getters, and unchanged result/issuer outputs. The old assertion that a rejected getter creates an aborted completion is corrected to INVALID_ID. Submitted requests retain their signed-out completion and existing first-poll behavior.

PS5 phase behavior remains unmeasured and is recorded in the library debt. This addresses ON C3 in #8005; no title compatibility claim is made.

Tested

Windows 11 Pro 10.0.26300; AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER. WinLibs GCC 15.2.0 UCRT r7; Release, BUILD_TESTING=ON.

Current rebase validation: base a6dcea9279b53b3a39c13695eac66f7c8b5b503c, head 2236680340b3de46e51eb2283e23fa2c84b3de97. Production behavior is unchanged from the original fix. The documentation merge preserves current-main A variants, native timeout validation and authorized-app-code validation. Existing regression coverage for those upstream changes remains present.

The full-configuration production targets and all selected fixtures build successfully without an overlay. All four selected runtime tests pass without skips (4/4, 0.40 s). Conventions, strict main-sync and whitespace checks pass. The overlap checker flags this PR itself and #6044; the latter moves GuestNpAuth.cpp unchanged (100% rename) and does not implement this fix.

cmake --build build --target libs relinker patched_libraries_tests guest_np_auth_tests guest_np_auth_authorized_app_code_tests guest_np_auth_authorized_app_dialog_tests --parallel 8
ctest --test-dir build -R '^(patched_libraries|guest_np_auth(_authorized_app_code|_authorized_app_dialog)?)$' -V --output-on-failure --no-tests=error
python -B tools/check_conventions.py --base origin/main
python -B tools/check_main_sync.py --base origin/main --strict
python -B tools/pr_overlap.py --branch codex/pr8611-rebase-20261022 --repo boykopovar/AnyPS5 --jobs 3
git diff --check origin/main...HEAD

The default all-target build and complete CTest suite were not run on the rebased head.

The remaining original validation below is historical and pinned to its stated revisions.

Base: 892a4f1328a14a123eca4af8f3c9ea5d176133ab. Fix: 6ce64bdfae1f41c0b862ae364b243b546d61edba.

Metric Before (base) After (fix)
Probe queries violating the unstarted request model 15/15 0/15
Extended guest_np_auth regression Fails Passes

The same probe checks two Poll calls and one Wait call for five paths: direct abort, or abort followed by each getter. Every fixed query returns INVALID_ID and preserves its output. The existing authorized-app-code test passes on base and fix; all three focused NP Auth tests pass on fix.

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DPython3_EXECUTABLE=C:/Python314/python.exe -DFFMPEG_PREBUILT_DIR=D:/Github/AnyPS5/build-runtime/externals/ffmpeg-9ac4cfd195f1
cmake --build build --parallel 6
ctest --test-dir build -R '^(patched_libraries|guest_np_auth(_authorized_app_code|_authorized_app_dialog)?)$' --output-on-failure
python tools/check_conventions.py --base origin/main
python tools/pr_overlap.py --branch codex/fix-np-auth-unstarted-abort

The overlap checker reports no confirmed overlap. I checked that #8471's A variants compose cleanly with all three files. For the incomplete comparisons, #6044 moves the unchanged test and #6977 adds a no-argument declaration on a stale base; neither supplies this fix.

No console module is needed by the regression. No PSN request or game run was performed.

Full all-target Windows Release build passed. All four relevant runtime tests passed without skips; 354 patched libraries loaded with zero failures. The full build used a temporary alignment adjustment confined to an unrelated existing test; it was restored afterward and is absent from the submitted diff.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4940404565 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8611). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-20T18:23:37Z. --- ### What An async request aborted before start is accepted by Poll/Wait as if it had been submitted: Poll reports running and then finishes with `SIGNED_OUT`. Calling a getter in between changes that completion to `ABORTED`, even though the getter rejects the start. Poll/Wait now require a started async request, and rejected getters leave the stored result alone. The getters still return `ABORTED`. This follows the request model already referenced by the library: shadPS4's [StartRequest](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/np/np_auth/np_auth.cpp#L83-L103) rejects a pre-start abort without creating a context, and [FindAsyncRequest](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/np/np_auth/np_auth.cpp#L226-L253) requires that context for Poll/Wait. The regression covers sync/async requests, repeated aborts and queries, the legacy/V3 getters, and unchanged result/issuer outputs. The old assertion that a rejected getter creates an aborted completion is corrected to `INVALID_ID`. Submitted requests retain their signed-out completion and existing first-poll behavior. PS5 phase behavior remains unmeasured and is recorded in the library debt. This addresses ON C3 in #8005; no title compatibility claim is made. ### Tested Windows 11 Pro 10.0.26300; AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER. WinLibs GCC 15.2.0 UCRT r7; Release, `BUILD_TESTING=ON`. Current rebase validation: base `a6dcea9279b53b3a39c13695eac66f7c8b5b503c`, head `2236680340b3de46e51eb2283e23fa2c84b3de97`. Production behavior is unchanged from the original fix. The documentation merge preserves current-main A variants, native timeout validation and authorized-app-code validation. Existing regression coverage for those upstream changes remains present. The full-configuration production targets and all selected fixtures build successfully without an overlay. All four selected runtime tests pass without skips (4/4, 0.40 s). Conventions, strict main-sync and whitespace checks pass. The overlap checker flags this PR itself and #6044; the latter moves `GuestNpAuth.cpp` unchanged (100% rename) and does not implement this fix. ```text cmake --build build --target libs relinker patched_libraries_tests guest_np_auth_tests guest_np_auth_authorized_app_code_tests guest_np_auth_authorized_app_dialog_tests --parallel 8 ctest --test-dir build -R '^(patched_libraries|guest_np_auth(_authorized_app_code|_authorized_app_dialog)?)$' -V --output-on-failure --no-tests=error python -B tools/check_conventions.py --base origin/main python -B tools/check_main_sync.py --base origin/main --strict python -B tools/pr_overlap.py --branch codex/pr8611-rebase-20261022 --repo boykopovar/AnyPS5 --jobs 3 git diff --check origin/main...HEAD ``` The default all-target build and complete CTest suite were not run on the rebased head. The remaining original validation below is historical and pinned to its stated revisions. Base: `892a4f1328a14a123eca4af8f3c9ea5d176133ab`. Fix: `6ce64bdfae1f41c0b862ae364b243b546d61edba`. | Metric | Before (base) | After (fix) | |---|---|---| | Probe queries violating the unstarted request model | 15/15 | 0/15 | | Extended `guest_np_auth` regression | Fails | Passes | The same probe checks two Poll calls and one Wait call for five paths: direct abort, or abort followed by each getter. Every fixed query returns `INVALID_ID` and preserves its output. The existing authorized-app-code test passes on base and fix; all three focused NP Auth tests pass on fix. ```sh cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DPython3_EXECUTABLE=C:/Python314/python.exe -DFFMPEG_PREBUILT_DIR=D:/Github/AnyPS5/build-runtime/externals/ffmpeg-9ac4cfd195f1 cmake --build build --parallel 6 ctest --test-dir build -R '^(patched_libraries|guest_np_auth(_authorized_app_code|_authorized_app_dialog)?)$' --output-on-failure python tools/check_conventions.py --base origin/main python tools/pr_overlap.py --branch codex/fix-np-auth-unstarted-abort ``` The overlap checker reports no confirmed overlap. I checked that #8471's A variants compose cleanly with all three files. For the incomplete comparisons, #6044 moves the unchanged test and #6977 adds a no-argument declaration on a stale base; neither supplies this fix. No console module is needed by the regression. No PSN request or game run was performed. Full all-target Windows Release build passed. All four relevant runtime tests passed without skips; 354 patched libraries loaded with zero failures. The full build used a temporary alignment adjustment confined to an unrelated existing test; it was restored afterward and is absent from the submitted diff. <!-- 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. --> ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-20 18:39:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T18:39:18Z.


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 6044 core/libs/tests/GuestNpAuth.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298397845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8611#issuecomment-6298397845). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T18:39:18Z. --- <!-- pr-overlap --> 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 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestNpAuth.cpp` |
xXPBSXx commented 2026-10-20 23:52:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T23:52:43Z.


Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main 339217ebc9 is clean. I built only guest_np_auth_tests; ctest -N -R guest_np_auth lists exactly one test.

Results (3 runs each):

  • PR head: guest_np_auth passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libSceNpAuth/Export.cpp with the version from the PR's merge base (892a4f1328), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's Export.cpp afterwards.

Not run: other platforms, the other NpAuth tests, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304443239 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8611#issuecomment-6304443239). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T23:52:43Z. --- Independent Windows run of this PR (data only). **Environment:** Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against `main` 339217ebc9 is clean. I built only `guest_np_auth_tests`; `ctest -N -R guest_np_auth` lists exactly one test. **Results (3 runs each):** - PR head: `guest_np_auth` passes 3/3. - Baseline: I kept the PR's test and replaced only `core/libs/prx/libSceNpAuth/Export.cpp` with the version from the PR's merge base (`892a4f1328`), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed `Require`). I restored the PR's `Export.cpp` afterwards. **Not run:** other platforms, the other NpAuth tests, the full repository CTest, and any title or console run. AI-assisted (Claude Code).
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!8611
No description provided.