fix(audioout2): guard context memory guest output #18039

Merged
DonRyuzaki merged 1 commit from upstream-pr/18039 into main 2026-11-12 07:20:22 +00:00
DonRyuzaki commented 2026-11-10 07:17:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DonRyuzaki on 2026-11-10T07:17:58Z.


What

Guard the output pointer of sceAudioOut2ContextQueryMemory with GuestCopyOut_nid_no_patch. Valid calls still return the same context memory size; an unwritable output now returns the existing invalid-argument code without crashing the host or changing errno. The console result for this invalid pointer remains unmeasured and is documented as a host-safety fallback. Open #14997 changes ContextCreate and #12863 changes a context callback, not this export; #14212 may require an ordinary debt-file rebase.

Tested

  • Ubuntu 24.04 WSL2, GCC 13.3, Release, BUILD_TESTING=ON. The new test against unchanged upstream code segfaulted at non-null guest output 0x10 (CTest exit 8).
  • Tested head ba78f6e58fceee8579bc5247929b1f48a42cb36f on main 53bb992782 passed the full default Linux runtime build, 3095/3095 Ninja steps. audio_out2_timing passed three consecutive focused CTest runs. The full CTest suite was not run.
  • Submitted head 96606c6208 on reviewed main 1539313883 changes the same AudioOut2 source, test and debt blobs as the tested head. The rebase added only unrelated AGC, library and debt changes. No full build was rerun on the submitted head.
  • Windows Python 3.12 conventions, git diff --check and clean-tree checks passed on the submitted head. Relevant open PR patches and discussions were compared manually because gh was unavailable for pr_overlap.py. No game or GPU test.

Checklist

  • Based on reviewed main; no open PR implements this export
  • One topic per PR
  • No code comments except technical debt
  • Unimplemented paths keep existing handling; silent stubs are documented
  • No notes or images added to the repository
  • No new third-party code
  • Generic behavior, not title-specific
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5237397128 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18039). Originally posted by [DonRyuzaki](https://github.com/DonRyuzaki) on 2026-11-10T07:17:58Z. --- ### What Guard the output pointer of sceAudioOut2ContextQueryMemory with GuestCopyOut_nid_no_patch. Valid calls still return the same context memory size; an unwritable output now returns the existing invalid-argument code without crashing the host or changing errno. The console result for this invalid pointer remains unmeasured and is documented as a host-safety fallback. Open #14997 changes ContextCreate and #12863 changes a context callback, not this export; #14212 may require an ordinary debt-file rebase. ### Tested - Ubuntu 24.04 WSL2, GCC 13.3, Release, BUILD_TESTING=ON. The new test against unchanged upstream code segfaulted at non-null guest output 0x10 (CTest exit 8). - Tested head ba78f6e58fceee8579bc5247929b1f48a42cb36f on main 53bb9927828957e110557a9eb710c7ba954f8732 passed the full default Linux runtime build, 3095/3095 Ninja steps. audio_out2_timing passed three consecutive focused CTest runs. The full CTest suite was not run. - Submitted head 96606c62087b0f253d5d6b068d5f621778f55930 on reviewed main 153931388353c2f424c2894e90f8b451c56b5833 changes the same AudioOut2 source, test and debt blobs as the tested head. The rebase added only unrelated AGC, library and debt changes. No full build was rerun on the submitted head. - Windows Python 3.12 conventions, git diff --check and clean-tree checks passed on the submitted head. Relevant open PR patches and discussions were compared manually because gh was unavailable for pr_overlap.py. No game or GPU test. ### Checklist - [x] Based on reviewed main; no open PR implements this export - [x] One topic per PR - [x] No code comments except technical debt - [x] Unimplemented paths keep existing handling; silent stubs are documented - [x] No notes or images added to the repository - [x] No new third-party code - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
gabichuuuuu commented 2026-11-10 11:12:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-10T11:12:29Z.

Review: COMMENTED


Read 96606c6208 against main.

Correctness. AudioOut2Context.cpp:sceAudioOut2ContextQueryMemory keeps the null checks and now writes the size through GuestCopyOut_nid_no_patch. It returns SCE_AUDIO_OUT2_ERROR_INVALID_ARGUMENT (0x80260502) when the copy fails. A valid output still receives CONTEXT_MEMORY. Saving and restoring errno is redundant on Linux, where GuestCopyOut_nid_no_patch already restores it on EFAULT. It is harmless and matches existing callers such as libSceAcm.

Test. On main, sceAudioOut2ContextQueryMemory(&params, (size_t*)0x10) stores straight through the pointer and faults, so the new rows in TestLowLatencyCallsRejectBadArguments fail there. With the change they check both the return code and errno.

Debt. The new entry says this is a host-safety fallback and the console result is unmeasured, which is what the code does.

Not run here; this is from reading the code.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5840906899 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18039#pullrequestreview-5840906899). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-10T11:12:29Z. **Review:** COMMENTED --- Read `96606c6208` against `main`. **Correctness.** `AudioOut2Context.cpp:sceAudioOut2ContextQueryMemory` keeps the null checks and now writes the size through `GuestCopyOut_nid_no_patch`. It returns `SCE_AUDIO_OUT2_ERROR_INVALID_ARGUMENT` (`0x80260502`) when the copy fails. A valid output still receives `CONTEXT_MEMORY`. Saving and restoring `errno` is redundant on Linux, where `GuestCopyOut_nid_no_patch` already restores it on `EFAULT`. It is harmless and matches existing callers such as `libSceAcm`. **Test.** On `main`, `sceAudioOut2ContextQueryMemory(&params, (size_t*)0x10)` stores straight through the pointer and faults, so the new rows in `TestLowLatencyCallsRejectBadArguments` fail there. With the change they check both the return code and `errno`. **Debt.** The new entry says this is a host-safety fallback and the console result is unmeasured, which is what the code does. Not run here; this is from reading the code. AI-assisted: yes.
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!18039
No description provided.