fix(libSceNpManager): refuse to poll or wait on a synchronous request #28776

Open
NobleBrains wants to merge 2 commits from upstream-pr/28776 into main
NobleBrains commented 2026-12-03 14:32:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-12-03T14:32:41Z.


What

sceNpPollAsync and sceNpWaitAsync treated a request from sceNpCreateRequest like an async one: they returned 0 and wrote SCE_NP_ERROR_SIGNED_OUT to *result. Firmware 13.42 returns SCE_NP_ERROR_INVALID_ID (0x80550015) for a synchronous request and leaves *result untouched (run in an emulator, not on a console).

Live requests now remember whether they were created as synchronous or async, and both functions refuse the synchronous ones. Async requests behave as before.

This is one part of #9277. The library initialization check (0x80550002), the SDK-dependent pending and blocking answers for async requests that were never given work, and requests with work in flight are not changed here.

Tested

The tests ran on f7b732db37, before the latest merge of main. main has not changed libSceNpManager or GuestNpManager.cpp since then.

  • Linux (container): guest_np_manager and guest_np_reachability pass (2/2). guest_np_manager now covers poll and wait on a synchronous request, also after abort and delete, and an id reused as the other kind.
  • macOS 15, Apple M4, x86_64 under Rosetta: both tests pass, on main 6f6f6c8e6b with this change and the open macOS build fixes #27201, #27739, #27843, #27767, #17425 and #27827.
  • Windows: not run.
  • No title was 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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

🤖 Generated with Claude Code

https://claude.ai/code/session_01GtiotZ92uvDBp76KjCvueG

Summary by CodeRabbit

  • Bug Fixes

    • Corrected polling and waiting behavior for network requests: synchronous requests now return an invalid-ID error, while missing or deleted requests return a not-found error.
    • Asynchronous requests continue to report their signed-out status, and invalid result pointers are handled without modifying valid result data.
  • Documentation

    • Clarified the expected results for polling and waiting on synchronous, asynchronous, and missing requests.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5628531305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28776). Originally posted by [NobleBrains](https://github.com/NobleBrains) on 2026-12-03T14:32:41Z. --- ### What `sceNpPollAsync` and `sceNpWaitAsync` treated a request from `sceNpCreateRequest` like an async one: they returned 0 and wrote `SCE_NP_ERROR_SIGNED_OUT` to `*result`. Firmware 13.42 returns `SCE_NP_ERROR_INVALID_ID` (`0x80550015`) for a synchronous request and leaves `*result` untouched ([run in an emulator](https://github.com/boykopovar/AnyPS5/issues/9277#issuecomment-6932568932), not on a console). Live requests now remember whether they were created as synchronous or async, and both functions refuse the synchronous ones. Async requests behave as before. This is one part of #9277. The library initialization check (`0x80550002`), the SDK-dependent pending and blocking answers for async requests that were never given work, and requests with work in flight are not changed here. ### Tested The tests ran on f7b732db37, before the latest merge of `main`. `main` has not changed libSceNpManager or `GuestNpManager.cpp` since then. - Linux (container): `guest_np_manager` and `guest_np_reachability` pass (2/2). `guest_np_manager` now covers poll and wait on a synchronous request, also after abort and delete, and an id reused as the other kind. - macOS 15, Apple M4, x86_64 under Rosetta: both tests pass, on `main` 6f6f6c8e6b with this change and the open macOS build fixes #27201, #27739, #27843, #27767, #17425 and #27827. - Windows: not run. - No title was tested. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01GtiotZ92uvDBp76KjCvueG <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected polling and waiting behavior for network requests: synchronous requests now return an invalid-ID error, while missing or deleted requests return a not-found error. * Asynchronous requests continue to report their signed-out status, and invalid result pointers are handled without modifying valid result data. * **Documentation** * Clarified the expected results for polling and waiting on synchronous, asynchronous, and missing requests. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-12-03 14:39:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T14:39:52Z.

Review: APPROVED


Reviewed — looks good

The request kind is retained for each live ID, and polling or waiting on a synchronous request returns INVALID_ID without writing the result.

What I ran

Reviewed head b97b3ff5bf7416e3f5b421493208aff2008b4fe7 using the prepared file snapshots in the Linux container. The pinned reader could not run because it attempted to append to a read-only log. I inspected the changed lines and relevant request lifecycle context in all three changed files; files.json lists three reviewed files and no exclusions.

sed -n '95,145p' files/core/libs/prx/libSceNpManager/Export.cpp
sed -n '975,1025p' files/core/libs/prx/libSceNpManager/Export.cpp
sed -n '1070,1170p' files/core/libs/prx/libSceNpManager/Export.cpp
rg -n 'AddRequest\(|liveRequests\.(count|find|erase|emplace|size)' files/core/libs/prx/libSceNpManager/Export.cpp

Results

Check Result Note
Changed code review passed All changed lines and relevant context inspected
Pinned reader failed Read-only logging prevented use
Tests not run Author reports Linux and macOS passes

Negative control

Not run; no test execution was performed during this review.

Findings

Blocking

None.

Non-blocking

None.

Sources

The request map records each ID's kind when created, and both API functions check that kind before writing the result: Export.cpp at the reviewed head, request creation, and poll and wait.

Not verified

Tests were not run independently. Windows behavior and title compatibility were not verified. The firmware behavior cited in the description is author-reported emulator evidence, not a console measurement.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6171927922 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28776#pullrequestreview-6171927922). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-12-03T14:39:52Z. **Review:** APPROVED --- # Reviewed — looks good The request kind is retained for each live ID, and polling or waiting on a synchronous request returns `INVALID_ID` without writing the result. ## What I ran Reviewed head `b97b3ff5bf7416e3f5b421493208aff2008b4fe7` using the prepared file snapshots in the Linux container. The pinned reader could not run because it attempted to append to a read-only log. I inspected the changed lines and relevant request lifecycle context in all three changed files; `files.json` lists three reviewed files and no exclusions. ```text sed -n '95,145p' files/core/libs/prx/libSceNpManager/Export.cpp sed -n '975,1025p' files/core/libs/prx/libSceNpManager/Export.cpp sed -n '1070,1170p' files/core/libs/prx/libSceNpManager/Export.cpp rg -n 'AddRequest\(|liveRequests\.(count|find|erase|emplace|size)' files/core/libs/prx/libSceNpManager/Export.cpp ``` ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All changed lines and relevant context inspected | | Pinned reader | failed | Read-only logging prevented use | | Tests | not run | Author reports Linux and macOS passes | ## Negative control Not run; no test execution was performed during this review. ## Findings ### Blocking None. ### Non-blocking None. ## Sources The request map records each ID's kind when created, and both API functions check that kind before writing the result: [Export.cpp at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/b97b3ff5bf7416e3f5b421493208aff2008b4fe7/core/libs/prx/libSceNpManager/Export.cpp#L115-L123), [request creation](https://github.com/boykopovar/AnyPS5/blob/b97b3ff5bf7416e3f5b421493208aff2008b4fe7/core/libs/prx/libSceNpManager/Export.cpp#L1000-L1007), and [poll and wait](https://github.com/boykopovar/AnyPS5/blob/b97b3ff5bf7416e3f5b421493208aff2008b4fe7/core/libs/prx/libSceNpManager/Export.cpp#L1137-L1156). ## Not verified Tests were not run independently. Windows behavior and title compatibility were not verified. The firmware behavior cited in the description is author-reported emulator evidence, not a console measurement. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 14:43:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T14:43:49Z.

Review: COMMENTED


Built and ran guest_np_manager and guest_np_reachability on Linux with this head integrated. Both passed. The new cases check that polling or waiting on a synchronous request leaves the result untouched, that deletion changes the answer to REQUEST_NOT_FOUND, and that a reused ID takes the kind recorded for its new request.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6171995501 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28776#pullrequestreview-6171995501). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T14:43:49Z. **Review:** COMMENTED --- Built and ran `guest_np_manager` and `guest_np_reachability` on Linux with this head integrated. Both passed. The new cases check that polling or waiting on a synchronous request leaves the result untouched, that deletion changes the answer to `REQUEST_NOT_FOUND`, and that a reused ID takes the kind recorded for its new request. AI-assisted: yes.
Plyxen commented 2026-12-04 12:50:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T12:50:41Z.

Review: APPROVED


Verified on Windows 11 with WinLibs GCC 15.2.0 r7 (Release). I used a tree at main 63b98e5bf8 (plus two unrelated commits of mine in libc and a LibreSSL test), with this PR applied together with #28881, #28810, #28806, #28776 and #28781, which touch separate files. I ran every strict_nid_filter, guest_audiodec*, guest_np_manager*, guest_np_reachability and HarfBuzz test (31): all pass before the change, and all pass in 3 of 3 runs with it.

That fills the "Windows: not run" gap. Negative control, with libSceNpManager/Export.cpp as on main and the new test kept: guest_np_manager aborts with "NpManager: poll must reject a sync request with InvalidId". guest_np_reachability passes before and after.

Not verified: the firmware 13.42 answer itself, which the description says was observed in an emulator, not on a console.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6189244826 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28776#pullrequestreview-6189244826). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-04T12:50:41Z. **Review:** APPROVED --- Verified on Windows 11 with WinLibs GCC 15.2.0 r7 (Release). I used a tree at `main` `63b98e5bf8` (plus two unrelated commits of mine in libc and a LibreSSL test), with this PR applied together with #28881, #28810, #28806, #28776 and #28781, which touch separate files. I ran every `strict_nid_filter`, `guest_audiodec*`, `guest_np_manager*`, `guest_np_reachability` and HarfBuzz test (31): all pass before the change, and all pass in 3 of 3 runs with it. That fills the "Windows: not run" gap. Negative control, with `libSceNpManager/Export.cpp` as on `main` and the new test kept: `guest_np_manager` aborts with "NpManager: poll must reject a sync request with InvalidId". `guest_np_reachability` passes before and after. Not verified: the firmware 13.42 answer itself, which the description says was observed in an emulator, not on a console. AI-assisted: yes (Claude Code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/28776:upstream-pr/28776'
git switch 'upstream-pr/28776'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/28776'
git switch 'upstream-pr/28776'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/28776'
git switch 'upstream-pr/28776'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/28776'
git switch 'main'
git merge --squash 'upstream-pr/28776'
git switch 'main'
git merge --ff-only 'upstream-pr/28776'
git switch 'main'
git merge 'upstream-pr/28776'
git push origin 'main'
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!28776
No description provided.