Astro's Playroom (PPSA01325): shader ABI resolution passes a different Shader* header pointer for the same code #2914

Closed
opened 2026-10-10 18:26:38 +00:00 by Unkown607 · 5 comments
Unkown607 commented 2026-10-10 18:26:38 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Unkown607 on 2026-10-10T18:26:38Z.


Astro's Playroom (PPSA01325): shader ABI resolution passes a different Shader* header pointer for the same code

Symptom

Astro's Playroom (PPSA01325, first-party title, FW 13.60) crashes while preparing a vertex-stage shader:

terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC graphics: AGC header pointer is outside the registered shader header

exit code 134 (SIGABRT). The throw is _readHeaderPod in Graphics/src/ShaderInputState.cpp:46.

Context

This is a different root cause from #2026 (closed): that was opengnm emitting shader headers without C++ tail padding, resolved by #2063. Here the header-size/padding is not the issue — the game is a first-party title compiled with Sony's toolchain.

Diagnosis

The title calls ResolveGraphicsAbi / ResolveShaderAbi / ResolveGraphicsStagesAbi with a Shader* whose code pointer matches a registered shader, but whose header pointer differs from the snapshot's headerAddress captured at registration time.

Upstream (ShaderRegistry.cpp) requires exact header-address identity and throws "rectangle ABI refers to a replaced shader header" in that case. On our fork we relaxed that to update snapshot.headerAddress under the mutex instead of throwing (9ad1b82a).

The problem: updating headerAddress without re-reading the header bytes leaves snapshot.header stale. The header contains absolute guest pointers (shader.user_data, shader.input_semantics, …) that are relative to the original header address. DecodeVertexStageInfo then computes offset = pointer - headerAddress against the new address, lands outside header.size(), and _readHeaderPod throws.

Proposed fix

When the header pointer changes, re-capture the header bytes from the new Shader* (the size is already available as shader->header_size):

snapshot->headerAddress = reinterpret_cast<std::uintptr_t>(shader);
snapshot->header.resize(shader->header_size);
std::memcpy(snapshot->header.data(), static_cast<const void*>(shader), shader->header_size);

This requires ShaderSnapshot::header to be mutable (like headerAddress), and should be applied at all three resolve sites.

Repro notes

  • Title: Astro's Playroom PPSA01325 (eboot.bin + bundled libc.prx/libSceNpCppWebApi.prx relinked).
  • Requires the title's game data (data/prein/save_data/*.xml, .odx/.codx/.cdx) to be present — without it the title crashes earlier (gatcha data lookup). Config-only dump is sufficient; textures/audio are not needed to reach this crash.
  • Reaches "Resident Load end", then a few Can't find model: data/prein/.../*.jxm warnings (non-fatal), then the throw.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5794073232 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2914). Originally posted by [Unkown607](https://github.com/Unkown607) on 2026-10-10T18:26:38Z. --- # Astro's Playroom (PPSA01325): shader ABI resolution passes a different `Shader*` header pointer for the same code ## Symptom Astro's Playroom (PPSA01325, first-party title, FW 13.60) crashes while preparing a vertex-stage shader: ``` terminate called after throwing an instance of 'std::runtime_error' what(): AGC graphics: AGC header pointer is outside the registered shader header ``` exit code 134 (SIGABRT). The throw is `_readHeaderPod` in `Graphics/src/ShaderInputState.cpp:46`. ## Context This is a **different root cause** from #2026 (closed): that was opengnm emitting shader headers without C++ tail padding, resolved by #2063. Here the header-size/padding is not the issue — the game is a first-party title compiled with Sony's toolchain. ## Diagnosis The title calls `ResolveGraphicsAbi` / `ResolveShaderAbi` / `ResolveGraphicsStagesAbi` with a `Shader*` whose `code` pointer matches a registered shader, but whose **header pointer differs** from the snapshot's `headerAddress` captured at registration time. Upstream (`ShaderRegistry.cpp`) requires exact header-address identity and throws `"rectangle ABI refers to a replaced shader header"` in that case. On our fork we relaxed that to update `snapshot.headerAddress` under the mutex instead of throwing (`9ad1b82a`). The problem: updating `headerAddress` without re-reading the header **bytes** leaves `snapshot.header` stale. The header contains absolute guest pointers (`shader.user_data`, `shader.input_semantics`, …) that are relative to the *original* header address. `DecodeVertexStageInfo` then computes `offset = pointer - headerAddress` against the *new* address, lands outside `header.size()`, and `_readHeaderPod` throws. ## Proposed fix When the header pointer changes, re-capture the header bytes from the new `Shader*` (the size is already available as `shader->header_size`): ```cpp snapshot->headerAddress = reinterpret_cast<std::uintptr_t>(shader); snapshot->header.resize(shader->header_size); std::memcpy(snapshot->header.data(), static_cast<const void*>(shader), shader->header_size); ``` This requires `ShaderSnapshot::header` to be `mutable` (like `headerAddress`), and should be applied at all three resolve sites. ## Repro notes - Title: Astro's Playroom PPSA01325 (eboot.bin + bundled `libc.prx`/`libSceNpCppWebApi.prx` relinked). - Requires the title's game data (`data/prein/save_data/*.xml`, `.odx`/`.codx`/`.cdx`) to be present — without it the title crashes earlier (gatcha data lookup). Config-only dump is sufficient; textures/audio are not needed to reach this crash. - Reaches "Resident Load end", then a few `Can't find model: data/prein/.../*.jxm` warnings (non-fatal), then the throw. AI-assisted: yes.
NRAPM commented 2026-10-10 21:26:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by NRAPM on 2026-10-10T21:26:22Z.


I have implemented and tested this fix on branch NRAPM:fix/agc-shader-abi-relocated-header (commit 7fb5b337, rebased on latest main integrating RegisteredHeader):

  • When ABI resolution encounters a relocated header matching SameHeader, RelocateSnapshotHeader publishes a new snapshot for the relocated header under driver mutex at the three resolve sites (ResolveGraphicsStagesAbi, ResolveShaderAbi, ResolveGraphicsAbi).
  • Keeps ShaderSnapshot immutable (no mutable members or technical debt needed).
  • Added test coverage in PreparedShaders.cpp with relocated full header copies.
  • Passed conventions checks: python tools/check_conventions.py --base origin/main and python -m unittest discover tools/tests.

PR #2969 was created with this change, but was auto-closed due to the intake pause (minimum 10 merged PRs threshold). Maintainers are welcome to carry or cherry-pick this commit (7fb5b337).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102347735 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2914#issuecomment-6102347735). Originally posted by [NRAPM](https://github.com/NRAPM) on 2026-10-10T21:26:22Z. --- I have implemented and tested this fix on branch [`NRAPM:fix/agc-shader-abi-relocated-header`](https://github.com/NRAPM/AnyPS5/tree/fix/agc-shader-abi-relocated-header) (commit `7fb5b337`, rebased on latest `main` integrating `RegisteredHeader`): - When ABI resolution encounters a relocated header matching `SameHeader`, `RelocateSnapshotHeader` publishes a new snapshot for the relocated header under driver `mutex` at the three resolve sites (`ResolveGraphicsStagesAbi`, `ResolveShaderAbi`, `ResolveGraphicsAbi`). - Keeps `ShaderSnapshot` immutable (no mutable members or technical debt needed). - Added test coverage in `PreparedShaders.cpp` with relocated full header copies. - Passed conventions checks: `python tools/check_conventions.py --base origin/main` and `python -m unittest discover tools/tests`. PR #2969 was created with this change, but was auto-closed due to the intake pause (minimum 10 merged PRs threshold). Maintainers are welcome to carry or cherry-pick this commit (`7fb5b337`).
oneandonlydean commented 2026-10-11 01:09:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T01:09:08Z.


#2856 (merged 10-10) keeps every registered header for the same code and resolves the ABI to the matching one. Does PPSA01325 still stop on current main?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104058414 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2914#issuecomment-6104058414). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T01:09:08Z. --- #2856 (merged 10-10) keeps every registered header for the same code and resolves the ABI to the matching one. Does PPSA01325 still stop on current main?
NRAPM commented 2026-10-11 10:22:28 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by NRAPM on 2026-10-11T10:22:28Z.


Yes, it still crashes on current main.

#2856 matches registered headers sharing code, but here the game passes a relocated copy at ABI resolve that was never registered. RegisteredHeader matches it via SameHeader, but leaves the original headerAddress and header bytes untouched. Downstream in _readHeaderPod, calculating offsets against the old headerAddress lands out of bounds and aborts.

UpdateSnapshotHeader updates snapshot.headerAddress and copies the new bytes to fix it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108031390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2914#issuecomment-6108031390). Originally posted by [NRAPM](https://github.com/NRAPM) on 2026-10-11T10:22:28Z. --- Yes, it still crashes on current main. #2856 matches registered headers sharing code, but here the game passes a relocated copy at ABI resolve that was never registered. `RegisteredHeader` matches it via `SameHeader`, but leaves the original `headerAddress` and header bytes untouched. Downstream in `_readHeaderPod`, calculating offsets against the old `headerAddress` lands out of bounds and aborts. `UpdateSnapshotHeader` updates `snapshot.headerAddress` and copies the new bytes to fix it.
MarcZX10 commented 2026-10-16 03:20:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T03:20:59Z.


I closed #5830 because it carried code from the intake-paused #2969, and independent reports reproduced regressions in existing tests. I then traced the current main at 5d9dcc42d: ResolveGraphicsStagesAbi selects a registered snapshot, and DecodeGraphicsPrograms resolves the program by code address and passes that snapshot's header bytes and base to DecodeVertexStageInfo. In the current source path I inspected, I do not see the caller's relocated Shader* reaching that decoder. Since the reported reproduction predates several changes to main, could you verify it again on the current head and share the exact current stack trace if it still fails? I have not opened a replacement until the failure is demonstrated against current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6207327436 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2914#issuecomment-6207327436). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T03:20:59Z. --- I closed #5830 because it carried code from the intake-paused #2969, and independent reports reproduced regressions in existing tests. I then traced the current `main` at `5d9dcc42d`: `ResolveGraphicsStagesAbi` selects a registered snapshot, and `DecodeGraphicsPrograms` resolves the program by code address and passes that snapshot's header bytes and base to `DecodeVertexStageInfo`. In the current source path I inspected, I do not see the caller's relocated `Shader*` reaching that decoder. Since the reported reproduction predates several changes to `main`, could you verify it again on the current head and share the exact current stack trace if it still fails? I have not opened a replacement until the failure is demonstrated against current `main`.
ebosido444-ai commented 2026-10-16 22:33:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-16T22:33:03Z.


Verified on current main (e9a3343) without the title binary, as asked.

A driver test that registers a vertex header and then resolves the ABI with a relocated copy of it — every embedded pointer moved into the copy, the copy itself never registered — fails today:

AGC driver: graphics ABI refers to a replaced shader header

RegisteredHeader → SameHeader is where it stops. RelocatedRegisters accepts a copy whose register array alone moved, and the fixed-field comparison accepts one whose only moved pointer is user_data, but a copy that moved its other referenced arrays with the header matches nothing, and the resolution refuses.

The _readHeaderPod throw in the report came from the fork's own relaxation (re-pointing headerAddress while keeping the snapshot's bytes, so B-relative pointers were computed against A-sized header bytes). Upstream never reaches that path: it refuses earlier. So the title's stop on main should be the refusal above, not AGC header pointer is outside the registered shader header — worth confirming against the title's log.

#6966 accepts a copy when every array it names still holds the registered bytes, so the registered header decodes exactly what the copy describes: no snapshot copy, no registry publish, ShaderSnapshot stays immutable, and a copy whose registers, context registers, specials or semantics differ (or whose arrays are unreadable) still throws. RelocatedHeaders() in tests/execution/PreparedShaders.cpp fails on unmodified main and passes with the change (agc_driver_prepared_shaders 11/11; Windows 11 26200.8117, winlibs GCC 15.2.0, GeForce GTX 1650 Ti 617.14 Vulkan).

That test is the reproduction: run it on main as it stands in #6966 and it fails there.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6225953687 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2914#issuecomment-6225953687). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-16T22:33:03Z. --- Verified on current `main` (`e9a3343`) without the title binary, as asked. A driver test that registers a vertex header and then resolves the ABI with a **relocated copy** of it — every embedded pointer moved into the copy, the copy itself never registered — fails today: ``` AGC driver: graphics ABI refers to a replaced shader header ``` `RegisteredHeader` → `SameHeader` is where it stops. `RelocatedRegisters` accepts a copy whose register array alone moved, and the fixed-field comparison accepts one whose only moved pointer is `user_data`, but a copy that moved its other referenced arrays with the header matches nothing, and the resolution refuses. The `_readHeaderPod` throw in the report came from the fork's own relaxation (re-pointing `headerAddress` while keeping the snapshot's bytes, so B-relative pointers were computed against A-sized header bytes). Upstream never reaches that path: it refuses earlier. So the title's stop on `main` should be the refusal above, not `AGC header pointer is outside the registered shader header` — worth confirming against the title's log. #6966 accepts a copy when every array it names still holds the registered bytes, so the registered header decodes exactly what the copy describes: no snapshot copy, no registry publish, `ShaderSnapshot` stays immutable, and a copy whose registers, context registers, specials or semantics differ (or whose arrays are unreadable) still throws. `RelocatedHeaders()` in `tests/execution/PreparedShaders.cpp` fails on unmodified `main` and passes with the change (`agc_driver_prepared_shaders` 11/11; Windows 11 26200.8117, winlibs GCC 15.2.0, GeForce GTX 1650 Ti 617.14 Vulkan). That test is the reproduction: run it on `main` as it stands in #6966 and it fails there. AI-assisted: yes.
Sign in to join this conversation.
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#2914
No description provided.