fix(libSceNgs2): return INVALID_GEOM_FLAG and the listener-address error from sceNgs2GeomCalcListener #8692

Merged
JAB-dev merged 1 commit from upstream-pr/8692 into main 2026-10-22 19:51:25 +00:00
JAB-dev commented 2026-10-20 21:12:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-20T21:12:51Z.


What

sceNgs2GeomCalcListener threw (and the process aborted) when a title passed a flags value above 1 or a null listener parameter. On the console it returns an error code and leaves the output untouched, so a title that checks the result now gets that code instead of a crash.

sceNgs2GeomCalcListener(param, outWork, flags) now returns 0x804A8461 (SCE_NGS2_ERROR_INVALID_GEOM_LISTENER_ADDRESS) for a null param, 0x804A8010 (INVALID_OUT_ADDRESS, as before) for a null outWork, and 0x804A8463 (SCE_NGS2_ERROR_INVALID_GEOM_FLAG) for any flags value above 1. The checks run in that order and nothing is written to outWork on any of them. Flags 0 and 1 and the matrix computation are unchanged; the meaning of flag bit 0 is not touched here. The other throws in the function (zero or non-finite vectors, a non-positive sound speed, an unrepresentable translation) stay.

Source: the PS5 SDK defines SCE_NGS2_ERROR_INVALID_GEOM_LISTENER_ADDRESS as 0x804A8461 and SCE_NGS2_ERROR_INVALID_GEOM_FLAG as 0x804A8463 (ngs2_errors.h) and documents only bit 0 of the flags, SCE_NGS2_GEOM_LISTENER_CALC_FLAG_COORIDINATE_LH (ngs2_geom.h). Firmware libSceNgs2.native.sprx (NID 1WsleK-MTkE), PS5 3.20 (function at 0x24d0) and 4.03 (0x2660): null param returns 0x804A8461, null outWork returns 0x804A8010, then flags > 1 returns 0x804A8463 straight to a ret before any store; the guards are identical in both. This is read from the disassembly, not measured on a console. No firmware bytes are in the repository.

The debt entry for sceNgs2GeomCalcListener drops "Unknown flags" from the list of cases that still throw.

Tested

Windows 11 x64, Release build, MinGW GCC 15.2.0 (WinLibs r7), -DBUILD_TESTING=ON, on main 73b6a4cc7. Linux not tested.

  • ngs2_geom: with the work buffer pre-filled with 0x5a, sceNgs2GeomCalcListener(nullptr, &work, 0) and (nullptr, &work, 2) and (nullptr, nullptr, 0) return 0x804A8461; (&param, &work, 2), (&param, &work, 0x80000000) and (&param, &work, 0xffffffff) return 0x804A8463; (&param, nullptr, 2) returns 0x804A8010; the buffer is byte-identical afterwards. The old throw-based assertions for a null parameter and for flags 2 and 0xffffffff are replaced by these.
  • With Geom.cpp from main, ngs2_geom aborts (uncaught exception, exit code 0xc0000409). With the change it passes.
  • python tools/check_conventions.py --base origin/main passes and git diff --check is clean.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4942570860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8692). Originally posted by [JAB-dev](https://github.com/JAB-dev) on 2026-10-20T21:12:51Z. --- ### What `sceNgs2GeomCalcListener` threw (and the process aborted) when a title passed a flags value above 1 or a null listener parameter. On the console it returns an error code and leaves the output untouched, so a title that checks the result now gets that code instead of a crash. `sceNgs2GeomCalcListener(param, outWork, flags)` now returns `0x804A8461` (`SCE_NGS2_ERROR_INVALID_GEOM_LISTENER_ADDRESS`) for a null `param`, `0x804A8010` (`INVALID_OUT_ADDRESS`, as before) for a null `outWork`, and `0x804A8463` (`SCE_NGS2_ERROR_INVALID_GEOM_FLAG`) for any `flags` value above 1. The checks run in that order and nothing is written to `outWork` on any of them. Flags 0 and 1 and the matrix computation are unchanged; the meaning of flag bit 0 is not touched here. The other throws in the function (zero or non-finite vectors, a non-positive sound speed, an unrepresentable translation) stay. Source: the PS5 SDK defines `SCE_NGS2_ERROR_INVALID_GEOM_LISTENER_ADDRESS` as 0x804A8461 and `SCE_NGS2_ERROR_INVALID_GEOM_FLAG` as 0x804A8463 (`ngs2_errors.h`) and documents only bit 0 of the flags, `SCE_NGS2_GEOM_LISTENER_CALC_FLAG_COORIDINATE_LH` (`ngs2_geom.h`). Firmware `libSceNgs2.native.sprx` (NID `1WsleK-MTkE`), PS5 3.20 (function at 0x24d0) and 4.03 (0x2660): null `param` returns 0x804A8461, null `outWork` returns 0x804A8010, then `flags > 1` returns 0x804A8463 straight to a `ret` before any store; the guards are identical in both. This is read from the disassembly, not measured on a console. No firmware bytes are in the repository. The debt entry for `sceNgs2GeomCalcListener` drops "Unknown flags" from the list of cases that still throw. ### Tested Windows 11 x64, Release build, MinGW GCC 15.2.0 (WinLibs r7), `-DBUILD_TESTING=ON`, on `main` 73b6a4cc7. Linux not tested. - `ngs2_geom`: with the work buffer pre-filled with 0x5a, `sceNgs2GeomCalcListener(nullptr, &work, 0)` and `(nullptr, &work, 2)` and `(nullptr, nullptr, 0)` return 0x804A8461; `(&param, &work, 2)`, `(&param, &work, 0x80000000)` and `(&param, &work, 0xffffffff)` return 0x804A8463; `(&param, nullptr, 2)` returns 0x804A8010; the buffer is byte-identical afterwards. The old throw-based assertions for a null parameter and for flags 2 and 0xffffffff are replaced by these. - With `Geom.cpp` from `main`, `ngs2_geom` aborts (uncaught exception, exit code 0xc0000409). With the change it passes. - `python tools/check_conventions.py --base origin/main` passes and `git diff --check` is clean. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-20 21:30:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T21:30:53Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 8609 core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp L19
PR 9233 core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp L19
PR 9337 core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp L19

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/include/Ngs2Types.hpp
PR 5797 core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp
docs/dev/debt/libSceNgs2.native.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6301925696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8692#issuecomment-6301925696). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T21:30:53Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 8609](https://www.github.com/boykopovar/AnyPS5/pull/8609) | `core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp` [L19](https://github.com/boykopovar/AnyPS5/blob/d6eafa54d0464258574fd2f71889754d05a5bc93/core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp#L19) | | | | [PR 9233](https://www.github.com/boykopovar/AnyPS5/pull/9233) | `core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp` [L19](https://github.com/boykopovar/AnyPS5/blob/d6eafa54d0464258574fd2f71889754d05a5bc93/core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp#L19) | | | | [PR 9337](https://www.github.com/boykopovar/AnyPS5/pull/9337) | `core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp` [L19](https://github.com/boykopovar/AnyPS5/blob/d6eafa54d0464258574fd2f71889754d05a5bc93/core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp#L19) | | | 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/include/Ngs2Types.hpp` | | [PR 5797](https://www.github.com/boykopovar/AnyPS5/pull/5797) | `core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp`<br>`docs/dev/debt/libSceNgs2.native.md` |
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!8692
No description provided.