fix(recompiler): read SRT words through a null user-data pointer as zero #2989

Merged
CnRJay merged 1 commit from upstream-pr/2989 into main 2026-10-10 23:49:13 +00:00
CnRJay commented 2026-10-10 19:56:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-10T19:56:23Z.


What

PPSA28416 (STAR WARS: Galactic Racer, UE5) stops on main while preparing a shader:

AGC driver: null or misaligned address

The shader's SRT walk does an s_load through s[4:5], a pointer taken from user data. The draw sets that pointer to 0. On the console the load does not run, because the program jumps over it with s_cbranch_execz. The capture evaluates every SRT read when the work is recorded, so it read through address 0 and threw. A null pointer loaded from memory is already handled: the read is poisoned and guarded at run time. A null pointer taken from user data was not.

Changes:

  • Evaluator::EvaluateRawRead: when its handle is not loaded from memory, a read through a null base reads 0 and is counted in ResourceSnapshot::nullRootReads. Reads through a non-null unmapped user-data pointer still throw.
  • materializeResult adds nullRootReads to RecompileResult::poisonedSrtReads, so a dispatch that reads them is not inserted in the dispatch cache, as for poisoned reads.
  • TechnicalDebt: the read is zero even if the program executes it. The console would fault there, and that fault is not modeled. The entry that said user-data pointers throw now covers only non-null ones.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 4080.

  • agc_shader_memory: the two cases that required null or misaligned address for a null user-data pointer now require the capture to count the reads, give a zero V#, and report at least as many poisoned SRT reads in the recompiled result. With the evaluator change disabled, the test fails with AGC driver: null or misaligned address.
  • Full suite: 714/714 pass (6 VideoOut tests skipped, as on main).
  • PPSA28416, on its bring-up branch that carries this commit: the shader is prepared and the title goes on.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4814027624 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2989). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-10T19:56:23Z. --- ### What PPSA28416 (STAR WARS: Galactic Racer, UE5) stops on `main` while preparing a shader: ``` AGC driver: null or misaligned address ``` The shader's SRT walk does an `s_load` through `s[4:5]`, a pointer taken from user data. The draw sets that pointer to 0. On the console the load does not run, because the program jumps over it with `s_cbranch_execz`. The capture evaluates every SRT read when the work is recorded, so it read through address 0 and threw. A null pointer loaded from memory is already handled: the read is poisoned and guarded at run time. A null pointer taken from user data was not. Changes: - `Evaluator::EvaluateRawRead`: when its handle is not loaded from memory, a read through a null base reads 0 and is counted in `ResourceSnapshot::nullRootReads`. Reads through a non-null unmapped user-data pointer still throw. - `materializeResult` adds `nullRootReads` to `RecompileResult::poisonedSrtReads`, so a dispatch that reads them is not inserted in the dispatch cache, as for poisoned reads. - TechnicalDebt: the read is zero even if the program executes it. The console would fault there, and that fault is not modeled. The entry that said user-data pointers throw now covers only non-null ones. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 4080. - `agc_shader_memory`: the two cases that required `null or misaligned address` for a null user-data pointer now require the capture to count the reads, give a zero V#, and report at least as many poisoned SRT reads in the recompiled result. With the evaluator change disabled, the test fails with `AGC driver: null or misaligned address`. - Full suite: 714/714 pass (6 VideoOut tests skipped, as on `main`). - PPSA28416, on its bring-up branch that carries this commit: the shader is prepared and the title goes on. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
adriadam10 commented 2026-10-10 23:49:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:49:10Z.


Checked the evaluator change (SrtEvaluator.cpp), the nullRootReads → poisonedSrtReads plumbing, and the TechnicalDebt entry. Scoped to a null base not loaded from memory; non-null unmapped user-data pointers still throw. Built on top of current main: agc_shader_memory passes; the rewritten cases fail to build without the change. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103466052 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2989#issuecomment-6103466052). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T23:49:10Z. --- Checked the evaluator change (`SrtEvaluator.cpp`), the `nullRootReads` → `poisonedSrtReads` plumbing, and the TechnicalDebt entry. Scoped to a null base not loaded from memory; non-null unmapped user-data pointers still throw. Built on top of current main: `agc_shader_memory` passes; the rewritten cases fail to build without the change. Merging.
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!2989
No description provided.