fix(libSceGnmDriverForNeoMode): return CommandFailed for null command buffers #16360

Merged
MarcZX10 merged 5 commits from upstream-pr/16360 into main 2026-11-09 11:46:03 +00:00
MarcZX10 commented 2026-11-06 11:52:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-06T11:52:34Z.


What

Four command writers in libSceGnmDriverForNeoMode/Export.cpp wrote through their command buffer pointer without a null check, so a null buffer crashed the host. The null-checking siblings in the same file (for example sceGnmSetPsShader350) return CommandFailed (-1).

  • fix(libSceGnmDriverForNeoMode): return CommandFailed for a null default-state command buffer: WriteHardwareState and WriteContextState, which back the sceGnmDrawInitDefaultHardwareState* and sceGnmDrawInitToDefaultContextState* exports, return -1 for a null buffer. The existing size-mismatch result (0) is unchanged. CommandFailed moves above the templates so they can use it.
  • fix(libSceGnmDriverForNeoMode): return CommandFailed for a null embedded-shader command buffer: sceGnmSetEmbeddedPsShader and sceGnmSetEmbeddedVsShader return -1 for a null buffer before reading the shader id.
  • One test commit after each fix (GuestGnmNeoDefaultState.cpp, GuestGnmNeoEmbedded.cpp).
  • docs(debt): note the unmeasured return for a null GNM command buffer: the console's result for a null buffer is not measured. To stay under the length limit of a debt entry, one clause of the embedded-shader entry ("since nothing here reads them") was dropped.

Tested

Linux, throwaway archive build of this head: BUILD-EXIT 0, ctest guest_gnm_neo_default_state and guest_gnm_neo_embedded (targets guest_gnm_neo_default_state_tests and guest_gnm_neo_embedded_tests) passed, 2 of 2. python3 tools/check_conventions.py against the merge base and git diff --check are clean. The new cases were not run against the unfixed code; that they fail without the fixes is reasoned from the code (a null dereference). Not run on Windows or macOS. Open PRs #16238 and #15605 edit stubs in the same Export.cpp but not these functions; a rebase conflict is possible.

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:5187407324 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16360). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-06T11:52:34Z. --- ### What Four command writers in `libSceGnmDriverForNeoMode/Export.cpp` wrote through their command buffer pointer without a null check, so a null buffer crashed the host. The null-checking siblings in the same file (for example `sceGnmSetPsShader350`) return `CommandFailed` (-1). - `fix(libSceGnmDriverForNeoMode): return CommandFailed for a null default-state command buffer`: `WriteHardwareState` and `WriteContextState`, which back the `sceGnmDrawInitDefaultHardwareState*` and `sceGnmDrawInitToDefaultContextState*` exports, return -1 for a null buffer. The existing size-mismatch result (0) is unchanged. `CommandFailed` moves above the templates so they can use it. - `fix(libSceGnmDriverForNeoMode): return CommandFailed for a null embedded-shader command buffer`: `sceGnmSetEmbeddedPsShader` and `sceGnmSetEmbeddedVsShader` return -1 for a null buffer before reading the shader id. - One `test` commit after each fix (`GuestGnmNeoDefaultState.cpp`, `GuestGnmNeoEmbedded.cpp`). - `docs(debt): note the unmeasured return for a null GNM command buffer`: the console's result for a null buffer is not measured. To stay under the length limit of a debt entry, one clause of the embedded-shader entry ("since nothing here reads them") was dropped. ### Tested Linux, throwaway archive build of this head: `BUILD-EXIT 0`, ctest `guest_gnm_neo_default_state` and `guest_gnm_neo_embedded` (targets `guest_gnm_neo_default_state_tests` and `guest_gnm_neo_embedded_tests`) passed, 2 of 2. `python3 tools/check_conventions.py` against the merge base and `git diff --check` are clean. The new cases were not run against the unfixed code; that they fail without the fixes is reasoned from the code (a null dereference). Not run on Windows or macOS. Open PRs #16238 and #15605 edit stubs in the same `Export.cpp` but not these functions; a rebase conflict is possible. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] 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!16360
No description provided.