fix(ngs2): return the voice-index error from sceNgs2RackGetVoiceHandle #5916

Merged
JosepBove merged 3 commits from upstream-pr/5916 into main 2026-10-16 19:54:29 +00:00
JosepBove commented 2026-10-14 15:33:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JosepBove on 2026-10-14T15:33:44Z.


What

Heretic + Hexen (PPSA26525 01.003.000, #5912) stops 1.5 s after start on main 69e7138ac, before its first frame:

sceNgs2RackGetVoiceHandle: invalid argument

The title creates a one-voice reverb rack (0x2001, max_voices = 1), takes voice 0 and asks for voice 1; sceNgs2RackGetVoiceHandle went through APS5_INVALID_ARG_EX for an index at or beyond the rack's voice count, which throws and ends the process (exit 0xC0000409; the title redirects stderr to app0/stderr.txt, so the message only shows under gdb). DOOM + DOOM II (PPSA21444 03.000.000, #5921) stops on the same line on main 84b01f9cd, measured here with the identical call sequence (voices 1 to 3 after voice 0), and STAR WARS: Dark Forces Remaster (PPSA19728, #4310) is reported with it; all three run Nightdive's KEX engine.

The index check now returns 0x804A8305 and leaves the output handle untouched. The null-output and rack-handle checks keep their order and codes. The value is the one the PS5 libSceNgs2.native.sprx export MwmHz8pAdAo returns for an index at or past the rack's voice count (firmware 10.01 at 0x11f10, 12.70 at 0x12130, and every module from 1.00 to 12.70 read in this comment), through the same error helper that answers 0x804A8010 for a null output, with the output handle written only on success. The technical-debt entry cites that module and notes that the export checks the rack handle before the output pointer and returns 0x804A8202 for a bad one, which this change leaves as it is on main.

#4788 proposed the same return value for Dark Forces and was closed on 2026-10-14 without a stated reason after twice conflicting with main. This change is rebased on current main, names two more titles that stop on it, and adds the regression as ngs2_voiceindex in the existing NGS2 suite.

Tested

Windows 11 Home (26200), AMD Ryzen 9 9950X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, bundled dependencies. Branch on main 84b01f9cd.

  • ngs2_voiceindex creates one-voice sampler, submixer, mastering and reverb racks through sceNgs2RackCreate with an explicit option, as the title does, and a default 256-voice sampler rack. For each it checks that the last valid index resolves, that the voice count, the count plus one and UINT32_MAX return 0x804A8305 with the output left at its sentinel, that a null output still returns INVALID_OUT_ADDRESS, that the last valid index resolves to the same handle afterwards, and that an unknown rack handle returns INVALID_RACK_HANDLE. The identical executable aborts against main's libSceNgs2.native.prx with the throw above and passes with this change.
  • ctest -R ngs2_: 11 of 11 pass.
  • Full ctest --parallel 8 --timeout 120: 1193 of 1194 pass on the rebuilt tree. The one failure, conventions_blob_reads, is a tools/ test new on main whose fixture's git tag fails on this machine because its git configuration signs tags; it fails the same way without this change.
  • python tools/check_conventions.py --base origin/main --head HEAD passes; git diff --check is clean.
  • Heretic + Hexen, relinked with --windows --registry (its sce_module/ and prx/ modules converted), ANYPS5_GPU='RTX 5090', 90 s with no input: on main it exits at 1.5 s as above; with this change it shows the logos, the Heretic episode menu at 30 s and the attract demo in game at 75 s at 120 FPS on the window counter, loads a level, plays the demo and writes a quick save. Audio and input were not checked. DOOM + DOOM II, same conversion, 120 s with no input: on main it exits during audio set-up on the same throw; with this change it logs kexAudioNgs2::InitReverbVoices: sceNgs2RackGetVoiceHandle failed (0x804a8305) four times, reaches the attract demo in game at 30 s and its main menu at 110 s at 120 FPS. Dark Forces was not run here.

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
  • Unblocks: PPSA26525 #5912; PPSA21444 #5921; PPSA19728 #4310 (same stop, not rerun here)
  • GPUs tested: n/a (NGS2 change; the title run used an RTX 5090, NVIDIA 616.92, Windows 11)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4860312200 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5916). Originally posted by [JosepBove](https://github.com/JosepBove) on 2026-10-14T15:33:44Z. --- ### What Heretic + Hexen (PPSA26525 01.003.000, #5912) stops 1.5 s after start on `main` 69e7138ac, before its first frame: ``` sceNgs2RackGetVoiceHandle: invalid argument ``` The title creates a one-voice reverb rack (`0x2001`, `max_voices = 1`), takes voice 0 and asks for voice 1; `sceNgs2RackGetVoiceHandle` went through `APS5_INVALID_ARG_EX` for an index at or beyond the rack's voice count, which throws and ends the process (exit `0xC0000409`; the title redirects stderr to `app0/stderr.txt`, so the message only shows under gdb). DOOM + DOOM II (PPSA21444 03.000.000, #5921) stops on the same line on `main` 84b01f9cd, measured here with the identical call sequence (voices 1 to 3 after voice 0), and STAR WARS: Dark Forces Remaster (PPSA19728, #4310) is reported with it; all three run Nightdive's KEX engine. The index check now returns `0x804A8305` and leaves the output handle untouched. The null-output and rack-handle checks keep their order and codes. The value is the one the PS5 `libSceNgs2.native.sprx` export `MwmHz8pAdAo` returns for an index at or past the rack's voice count (firmware 10.01 at `0x11f10`, 12.70 at `0x12130`, and every module from 1.00 to 12.70 read in [this comment](https://github.com/boykopovar/AnyPS5/pull/5916#issuecomment-6172832590)), through the same error helper that answers `0x804A8010` for a null output, with the output handle written only on success. The technical-debt entry cites that module and notes that the export checks the rack handle before the output pointer and returns `0x804A8202` for a bad one, which this change leaves as it is on `main`. #4788 proposed the same return value for Dark Forces and was closed on 2026-10-14 without a stated reason after twice conflicting with `main`. This change is rebased on current `main`, names two more titles that stop on it, and adds the regression as `ngs2_voiceindex` in the existing NGS2 suite. ### Tested Windows 11 Home (26200), AMD Ryzen 9 9950X3D, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, bundled dependencies. Branch on `main` 84b01f9cd. - `ngs2_voiceindex` creates one-voice sampler, submixer, mastering and reverb racks through `sceNgs2RackCreate` with an explicit option, as the title does, and a default 256-voice sampler rack. For each it checks that the last valid index resolves, that the voice count, the count plus one and `UINT32_MAX` return `0x804A8305` with the output left at its sentinel, that a null output still returns `INVALID_OUT_ADDRESS`, that the last valid index resolves to the same handle afterwards, and that an unknown rack handle returns `INVALID_RACK_HANDLE`. The identical executable aborts against `main`'s `libSceNgs2.native.prx` with the throw above and passes with this change. - `ctest -R ngs2_`: 11 of 11 pass. - Full `ctest --parallel 8 --timeout 120`: 1193 of 1194 pass on the rebuilt tree. The one failure, `conventions_blob_reads`, is a `tools/` test new on `main` whose fixture's `git tag` fails on this machine because its git configuration signs tags; it fails the same way without this change. - `python tools/check_conventions.py --base origin/main --head HEAD` passes; `git diff --check` is clean. - Heretic + Hexen, relinked with `--windows --registry` (its `sce_module/` and `prx/` modules converted), `ANYPS5_GPU='RTX 5090'`, 90 s with no input: on `main` it exits at 1.5 s as above; with this change it shows the logos, the Heretic episode menu at 30 s and the attract demo in game at 75 s at 120 FPS on the window counter, loads a level, plays the demo and writes a quick save. Audio and input were not checked. DOOM + DOOM II, same conversion, 120 s with no input: on `main` it exits during audio set-up on the same throw; with this change it logs `kexAudioNgs2::InitReverbVoices: sceNgs2RackGetVoiceHandle failed (0x804a8305)` four times, reaches the attract demo in game at 30 s and its main menu at 110 s at 120 FPS. Dark Forces was not run here. ### Checklist - [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] Unblocks: PPSA26525 #5912; PPSA21444 #5921; PPSA19728 #4310 (same stop, not rerun here) - [x] GPUs tested: n/a (NGS2 change; the title run used an RTX 5090, NVIDIA 616.92, Windows 11) - [x] AI-assisted: yes
fma-rc commented 2026-10-14 16:12:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-14T16:12:52Z.


I checked the value against the PS5 module. In libSceNgs2.native.sprx from PS5 firmware 10.01 (export MwmHz8pAdAo at 0x11f10) and 12.70 (at 0x12130), an index at or past the rack's voice count returns 0x804A8305. The value goes through the same error helper that returns 0x804A8010 for a null output, and the output handle is written only on success. The constant is in this export in all 41 firmware modules from 1.00 to 12.70 that I could read, so the debt entry can cite a PS5 source instead of prosper and shadPS4.

One thing outside this change: the same export validates the rack handle first and returns 0x804A8202 for a bad one, before it looks at the output pointer. main checks the output first and returns 0x804A0261 for a bad rack, and 0x804A0261 does not appear in this export in any of those modules. That could be a separate PR.

On main e34c47921 with this PR (17f8bb521), ctest -R ngs2_ passes 11 of 11 on Linux, including ngs2_voiceindex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6172832590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5916#issuecomment-6172832590). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-14T16:12:52Z. --- I checked the value against the PS5 module. In `libSceNgs2.native.sprx` from PS5 firmware 10.01 (export `MwmHz8pAdAo` at 0x11f10) and 12.70 (at 0x12130), an index at or past the rack's voice count returns 0x804A8305. The value goes through the same error helper that returns 0x804A8010 for a null output, and the output handle is written only on success. The constant is in this export in all 41 firmware modules from 1.00 to 12.70 that I could read, so the debt entry can cite a PS5 source instead of prosper and shadPS4. One thing outside this change: the same export validates the rack handle first and returns 0x804A8202 for a bad one, before it looks at the output pointer. `main` checks the output first and returns 0x804A0261 for a bad rack, and 0x804A0261 does not appear in this export in any of those modules. That could be a separate PR. On `main` e34c47921 with this PR (17f8bb521), `ctest -R ngs2_` passes 11 of 11 on Linux, including `ngs2_voiceindex`.
github-actions[bot] commented 2026-10-15 12:11:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:11:36Z.


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 1384 core/libs/prx/libSceNgs2.native/CMakeLists.txt
core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp
core/libs/prx/libSceNgs2.native/src/Rack.cpp
PR 5797 core/libs/prx/libSceNgs2.native/CMakeLists.txt
core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp
docs/dev/debt/libSceNgs2.native.md
PR 5974 docs/dev/debt/libSceNgs2.native.md
PR 6044 core/libs/prx/libSceNgs2.native/CMakeLists.txt
PR 6447 docs/dev/debt/libSceNgs2.native.md
PR 6594 docs/dev/debt/libSceNgs2.native.md
PR 6680 core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp
docs/dev/debt/libSceNgs2.native.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191739149 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5916#issuecomment-6191739149). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:11:36Z. --- <!-- 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 1384](https://www.github.com/boykopovar/AnyPS5/pull/1384) | `core/libs/prx/libSceNgs2.native/CMakeLists.txt`<br>`core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp`<br>`core/libs/prx/libSceNgs2.native/src/Rack.cpp` | | [PR 5797](https://www.github.com/boykopovar/AnyPS5/pull/5797) | `core/libs/prx/libSceNgs2.native/CMakeLists.txt`<br>`core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp`<br>`docs/dev/debt/libSceNgs2.native.md` | | [PR 5974](https://www.github.com/boykopovar/AnyPS5/pull/5974) | `docs/dev/debt/libSceNgs2.native.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceNgs2.native/CMakeLists.txt` | | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `docs/dev/debt/libSceNgs2.native.md` | | [PR 6594](https://www.github.com/boykopovar/AnyPS5/pull/6594) | `docs/dev/debt/libSceNgs2.native.md` | | [PR 6680](https://www.github.com/boykopovar/AnyPS5/pull/6680) | `core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp`<br>`docs/dev/debt/libSceNgs2.native.md` |
jotitadev commented 2026-10-15 19:12:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T19:12:44Z.

Review: COMMENTED


Linux run: head 9926c6b76 merged onto main 44df21632 (clean merge). Adds a Linux run to the Windows one in the description.

Machine: Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests (Release, BUILD_TESTING=ON).

  • Build: full build passes.
  • Ngs2 tests: all 11 ngs2_* tests pass with the PR, ngs2_voiceindex included. With main's Rack.cpp and the PR's test, ngs2_voiceindex aborts with "sceNgs2RackGetVoiceHandle: invalid argument", the line from the title logs.
  • Non-GPU suite (ctest -E "^agc"): no regressions; the only failures are file_writer_binary and file_writer_text, which fail on main on this machine too.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5538585824 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5916#pullrequestreview-5538585824). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T19:12:44Z. **Review:** COMMENTED --- **Linux run: head `9926c6b76` merged onto `main` `44df21632` (clean merge).** Adds a Linux run to the Windows one in the description. Machine: Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests (Release, `BUILD_TESTING=ON`). - **Build:** full build passes. - **Ngs2 tests:** all 11 `ngs2_*` tests pass with the PR, `ngs2_voiceindex` included. With `main`'s `Rack.cpp` and the PR's test, `ngs2_voiceindex` aborts with "sceNgs2RackGetVoiceHandle: invalid argument", the line from the title logs. - Non-GPU suite (`ctest -E "^agc"`): no regressions; the only failures are `file_writer_binary` and `file_writer_text`, which fail on `main` on this machine too. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
JJenkx commented 2026-10-15 20:09:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-15T20:09:57Z.


Additional title confirmation: Quake II (PPSA09477), content version 01.003.000.

On current main 44df21632125dbe3113a19173e7ebb879da53003, with the common validator-teardown build repair from #6476, the first native startup aborts at sceNgs2RackGetVoiceHandle: invalid argument before a window appears (exit 134).

Adding exactly this PR’s three commits, preserving their authorship, removes that stop. The title logs three InitReverbVoices failures with 0x804a8305, continues through shader loading and reaches renderer initialization. It then exits with SIGSEGV after about four seconds; this is a startup-blocker confirmation, not a playable-title claim. No game input was injected.

Full libs build succeeded. After rebuilding all NGS2 test executables, all 11 NGS2 CTests passed, 0 skipped (0.42 s). An earlier run against stale test executables failed three tests and is excluded from the final test result.

Environment: Arch Linux, Ryzen 9 7950X, Radeon RX 6650 XT, RADV Mesa 26.2.4-arch1.1. Local validation head: 86322c5668718c31ebc0b6bae4b504f3bf3c30c7 = current main + #6476 + this PR. No additional production changes, title-specific bypasses, or audio-quality/performance claim. AI-assisted validation.

Follow-up: Quake II bring-up #6554 records the later startup failure. A logging-only diagnostic build reached a 3D scene, presented at least 4,254 frames and closed normally after 83.78 seconds. Normal Release startup remains unreliable; no additional functional fix, input validation or playable-title claim is implied.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6201279555 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5916#issuecomment-6201279555). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-15T20:09:57Z. --- Additional title confirmation: **Quake II (PPSA09477), content version 01.003.000**. On current main `44df21632125dbe3113a19173e7ebb879da53003`, with the common validator-teardown build repair from #6476, the first native startup aborts at `sceNgs2RackGetVoiceHandle: invalid argument` before a window appears (exit 134). Adding exactly this PR’s three commits, preserving their authorship, removes that stop. The title logs three `InitReverbVoices` failures with `0x804a8305`, continues through shader loading and reaches renderer initialization. It then exits with SIGSEGV after about four seconds; this is **a startup-blocker confirmation, not a playable-title claim**. No game input was injected. Full `libs` build succeeded. After rebuilding all NGS2 test executables, all **11 NGS2 CTests passed, 0 skipped** (0.42 s). An earlier run against stale test executables failed three tests and is excluded from the final test result. Environment: Arch Linux, Ryzen 9 7950X, Radeon RX 6650 XT, RADV Mesa 26.2.4-arch1.1. Local validation head: `86322c5668718c31ebc0b6bae4b504f3bf3c30c7` = current main + #6476 + this PR. No additional production changes, title-specific bypasses, or audio-quality/performance claim. AI-assisted validation. Follow-up: [Quake II bring-up #6554](https://github.com/boykopovar/AnyPS5/discussions/6554) records the later startup failure. A logging-only diagnostic build reached a 3D scene, presented at least 4,254 frames and closed normally after 83.78 seconds. Normal Release startup remains unreliable; no additional functional fix, input validation or playable-title claim is implied.
adriadam10 commented 2026-10-16 18:40:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T18:40:48Z.


Checked build and the NGS2 ctest scope on current main (10/10 pass, ngs2_voiceindex included). The return value 0x804A8305 and the "output written only on success" behaviour match the PS5 libSceNgs2.native.sprx export MwmHz8pAdAo as read by @fma-rc, and the Linux runs by @jotitadev and @johnohhh1 show the new test aborting on main's Rack.cpp and passing here. The technical-debt entry covers the differing rack-handle/output check order. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6222316357 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5916#issuecomment-6222316357). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T18:40:48Z. --- Checked build and the NGS2 ctest scope on current main (10/10 pass, `ngs2_voiceindex` included). The return value `0x804A8305` and the "output written only on success" behaviour match the PS5 `libSceNgs2.native.sprx` export `MwmHz8pAdAo` as read by @fma-rc, and the Linux runs by @jotitadev and @johnohhh1 show the new test aborting on main's `Rack.cpp` and passing here. The technical-debt entry covers the differing rack-handle/output check order. Merging once CI is green.
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!5916
No description provided.