shader: fix ASTRO BOT (PPSA21567) startup crash on a null SRT table pointer #1528

Closed
github-bot wants to merge 3 commits from gh-pr/1528/head into gh-pr/1528/base
Owner

@⁠MIKL99999 on GitHub · 2026-10-15 15:26 UTC · original
MIKL99999:claude/fix-ppsa21567-crash-t3xfx8 → main · +108 −8 · 4 files · 3 commits · closed without merging

Game: ASTRO BOT (PPSA21567, EU, v1.018)

Problem: The game crashed right at startup, after compiling its first shaders, with Unhandled host exception ... address=0x0000000000000018 on build KytyPS5-2026-10-12-df5b9b9. Full log attached. The runtimeLinker.cpp:711 line in the log is only where the crash gets reported.

Cause: Before compiling a shader, the SRT walker reads the shader's resource tables to find out which buffers and textures it uses. When it can't decide a branch in advance, it walks both sides. On one side the table pointer is null, so SrtReadCapture::ReadOrdinary (called from SrtWalker::EvaluateRawRead) copied from address 0x18 and crashed.

Fix: Ordinary SRT reads below 64 KiB, where nothing is ever mapped, now return zero instead of reading host memory, and they are not recorded as specialization reads. The compiled (JIT) walker also bails out on such tables and falls back to the interpreted walk. That part is hardening; it was not on the crash path.

Trade-off: if the GPU really takes the branch with the null table, its descriptors come out empty (empty buffer or null image), so rendering could be wrong there, but it no longer crashes.

Testing:

AI use: Claude (Anthropic) found the cause from the crash log, wrote the fix and the tests. I tested the build in the game on Windows and reviewed the change before opening this PR.

**@⁠MIKL99999** on GitHub · 2026-10-15 15:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1528) `MIKL99999:claude/fix-ppsa21567-crash-t3xfx8` → `main` · +108 −8 · 4 files · 3 commits · closed without merging **Game:** ASTRO BOT (PPSA21567, EU, v1.018) **Problem:** The game crashed right at startup, after compiling its first shaders, with `Unhandled host exception ... address=0x0000000000000018` on build KytyPS5-2026-10-12-df5b9b9. Full log attached. The `runtimeLinker.cpp:711` line in the log is only where the crash gets reported. **Cause:** Before compiling a shader, the SRT walker reads the shader's resource tables to find out which buffers and textures it uses. When it can't decide a branch in advance, it walks both sides. On one side the table pointer is null, so `SrtReadCapture::ReadOrdinary` (called from `SrtWalker::EvaluateRawRead`) copied from address 0x18 and crashed. **Fix:** Ordinary SRT reads below 64 KiB, where nothing is ever mapped, now return zero instead of reading host memory, and they are not recorded as specialization reads. The compiled (JIT) walker also bails out on such tables and falls back to the interpreted walk. That part is hardening; it was not on the crash path. Trade-off: if the GPU really takes the branch with the null table, its descriptors come out empty (empty buffer or null image), so rendering could be wrong there, but it no longer crashes. **Testing:** - With this change the game gets past startup on Windows. - New cases in `tests/ResourceMaterializationTests.cpp`. Run locally on Linux. - CI is green on Windows, Linux and macOS on my fork: https://github.com/MIKL99999/KytyPS5/actions/runs/38740853701 **AI use:** Claude (Anthropic) found the cause from the crash log, wrote the fix and the tests. I tested the build in the game on Windows and reviewed the change before opening this PR.
* Read zero for SRT walker reads through a null table pointer

PPSA21567 crashed at startup with a host access violation at address 0x18.
The return addresses in the official build map to SrtReadCapture::ReadOrdinary
called from SrtWalker::EvaluateRawRead: the walker followed a null scalar table
pointer (a branch it could not decide walks both successors) and memcpy'd from
0x18.

Ordinary reads below 64 KiB, where nothing is ever mapped, now read zero and are
not recorded as specialization reads. The compiled x86 walker bails out on such
pointers, and RefreshFlatBuffer falls back to the interpreted walk instead of
failing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018pB2mExUCVZzQNyBrmWgLn

* Test the SRT walker through a null nested table

A valid root table holding a null child pointer is the realistic shape of
the PPSA21567 crash. Without the fix the compiled walker faults reading
the child table; with it the walk falls back and reads zero.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018pB2mExUCVZzQNyBrmWgLn

* shader: follow src/.clang-tidy naming and clang-format in the SRT null-page fix

Rename the new constant to NULL_PAGE_END (ConstexprVariableCase is UPPER_CASE),
format the RefreshFlatBuffer fallback call with the pinned clang-format 22.1.3,
and drop an unverified claim from the comment: the walker reads zero for any
null-page ordinary read, whether or not the shader would skip it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018pB2mExUCVZzQNyBrmWgLn

---------

Co-authored-by: Claude <[email protected]>
Review of KytyPS5/KytyPS5#1528 (Nawid3333) showed that a null table read at
+0x20000 still faulted: the guard compared the final address with 64 KiB, so
the compiled walker emitted no check for offsets past it and the interpreted
paths passed the read to memcpy.

Guest memory starts at HOST_SYSTEM_MANAGED_MIN (0x40000), so use that as the
bound. The compiled walker now checks the table pointer itself and bails for
any table below it; the no-reader interpreted read checks both the table
pointer and the address; the captured read checks the address. Add the
reviewer's test at offsets 0x18 and 0x20000.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018pB2mExUCVZzQNyBrmWgLn
CodeRabbit on KytyPS5/KytyPS5#1528: with a null table and an offset of
0x40000 or more, the captured read's address passed ReadOrdinary's check,
so it copied host memory and recorded the range.

EvaluateRawRead now reads zero when the table pointer is below guest memory
and the read would copy host memory: no reader, or a capture without a
source reader. Readers that can refuse a read still get it, so strict and
specialization reads of a null table keep failing as ResourceTracking
expects. Applying the check to every reader breaks resource_tracking_tests.
The null-table test now also covers offsets 0x40000 and 0x100000.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018pB2mExUCVZzQNyBrmWgLn
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:50 +00:00
github-bot closed this pull request 2026-11-26 09:58:50 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 15:30 UTC · original · edited 2026-10-15 22:36 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 39435268-c5e0-48ac-afe2-e05dc3f04d48
📥 Commits

Reviewing files that changed from the base of the PR and between 4d7110b43c and bd8f0dae50.

📒 Files selected for processing: 3
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.h
  • tests/ScalarProvenanceTests.cpp
🚧 Files skipped from review as they are similar to previous changes: 2
  • tests/ScalarProvenanceTests.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

📝 Walkthrough

The SRT walker uses 0x40000 as the guest-memory threshold. Reads below the threshold produce zero in ordinary and raw-read paths under the described reader conditions. The compiled walker falls back for table pointers below the threshold, adjusted for negative offsets. When compiled walking returns false, RefreshFlatBuffer continues with interpreted evaluation. Tests cover direct, captured, nested, and compiled SRT reads through null pointers.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to bd8f0

Null-table reads now resolve safely, and the fallback refreshes results after compiled-walk failure. No identified merge blocker remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the shader fix, the affected game, and the null SRT table pointer startup crash.
Description check Passed The description directly explains the ASTRO BOT startup crash, its SRT walker cause, the implemented fix, trade-offs, and testing.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 15:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1528#issuecomment-6195836266) · edited 2026-10-15 22:36 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1528?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `39435268-c5e0-48ac-afe2-e05dc3f04d48` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 4d7110b43c256c2c65a168743687888cdc39719c and bd8f0dae504848b3ff7c39abfa7d8aeea4bea6b2. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 3</strong></summary> <dl> <dd> * `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.h` * `tests/ScalarProvenanceTests.cpp` </dd> </dl> </details> <details> <summary><strong>🚧 Files skipped from review as they are similar to previous changes: 2</strong></summary> <dl> <dd> * tests/ScalarProvenanceTests.cpp * src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The SRT walker uses `0x40000` as the guest-memory threshold. Reads below the threshold produce zero in ordinary and raw-read paths under the described reader conditions. The compiled walker falls back for table pointers below the threshold, adjusted for negative offsets. When compiled walking returns false, `RefreshFlatBuffer` continues with interpreted evaluation. Tests cover direct, captured, nested, and compiled SRT reads through null pointers. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"bd8f0dae504848b3ff7c39abfa7d8aeea4bea6b2" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>bd8f0</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `bd8f0` --> <!-- final_review_risk_coverage:{"sourceCommitId":"bd8f0dae504848b3ff7c39abfa7d8aeea4bea6b2","coveredCommitId":"bd8f0dae504848b3ff7c39abfa7d8aeea4bea6b2","kind":"reviewed"} --> Null-table reads now resolve safely, and the fallback refreshes results after compiled-walk failure. No identified merge blocker remains. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 4 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly identifies the shader fix, the affected game, and the null SRT table pointer startup crash. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the ASTRO BOT startup crash, its SRT walker cause, the implemented fix, trade-offs, and testing. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1528)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-15 18:48 UTC · original

I checked this with a CPU test in tests/ScalarProvenanceTests.cpp (Windows 11, clang-cl 19.1.5, Release). User data holds a zero table pointer and the test reads through it three ways: a capture walk (SrtReadCapture, so ReadOrdinary), SrtWalker::Evaluate (EvaluateRawRead), and RefreshFlatBuffer with no reader, which runs the compiled walker. I ran each of the three checks on its own:

  • Read at +0x18 (the Astro Bot case): on 9e41d832 each check faults (0xC0000005); with this PR the test passes.
  • Read at +0x20000: with this PR each check still faults. Here first >= NULL_PAGE_END, so the new JIT check isn't emitted and the table load runs on the null pointer, and the interpreter guards (address < NULL_PAGE_END) let the read through to memcpy.

Guest memory starts at 0x40000 (HOST_SYSTEM_MANAGED_MIN in memoryAddressSpace.inc), so nothing below that can be guest data. A variant that compares the table pointer itself against 0x40000 in the compiled walker, right after and rdi, r9 and before the range checks, uses 0x40000 as the interpreter threshold, and doesn't record those reads passes the test at both offsets: github.com/Nawid3333/KytyPS5@df55cb78. I haven't seen offsets that large in the Astro Bot logs, so this is an edge case, not a blocker.

Test (Fixture maps s2/s3 to user_data[0..1], user_data_base = 2)
void TestNullTablePointerReadsZero() {
  Fixture fixture;
  const auto memory = fixture.AddMemory(ResourceKind::ScalarAddress);
  const auto low = fixture.Emit(ValueOpcode::GetUserData,
                                {Value(static_cast<ScalarReg>(2))});
  const auto high = fixture.Emit(ValueOpcode::GetUserData,
                                 {Value(static_cast<ScalarReg>(3))});
  const auto value =
      RawRead(fixture, Address(fixture, low, high), Value(0x18u), memory);
  LoadBuffer(fixture, {value, Value(0u), Value(16u), Value(0u)});
  fixture.Plan();
  const auto plan = ExtractResourcePlan(fixture.program);
  Check(plan.srt_code != nullptr, "user-data table reads were not compiled");

  const std::array user_data{0u, 0u};
  const SrtRuntime runtime{.user_data = user_data};
  std::vector<std::pair<uint64_t, uint64_t>> ranges;
  SrtReadCapture capture(runtime, ranges);
  std::vector<uint32_t> flat;
  Check(SrtWalker(plan, capture.ObservedRuntime()).RefreshFlatBuffer(flat) &&
            flat == std::vector<uint32_t>{0u} && ranges.empty(),
        "captured walk did not read a null table as zero");

  uint32_t word = 1u;
  Check(SrtWalker(plan, runtime).Evaluate(plan.srt_reads[0].value, word) &&
            word == 0u,
        "ordinary read did not read a null table as zero");

  flat.clear();
  Check(SrtWalker(plan, runtime).RefreshFlatBuffer(flat) &&
            flat == std::vector<uint32_t>{0u},
        "compiled walk did not read a null table as zero");
}

AI use: Claude Code wrote the test and the variant, ran them on my machine and wrote this comment.

**@⁠Nawid3333** on GitHub · 2026-10-15 18:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1528#issuecomment-6199755050) I checked this with a CPU test in `tests/ScalarProvenanceTests.cpp` (Windows 11, clang-cl 19.1.5, Release). User data holds a zero table pointer and the test reads through it three ways: a capture walk (`SrtReadCapture`, so `ReadOrdinary`), `SrtWalker::Evaluate` (`EvaluateRawRead`), and `RefreshFlatBuffer` with no reader, which runs the compiled walker. I ran each of the three checks on its own: - Read at `+0x18` (the Astro Bot case): on 9e41d832 each check faults (0xC0000005); with this PR the test passes. - Read at `+0x20000`: with this PR each check still faults. Here `first >= NULL_PAGE_END`, so the new JIT check isn't emitted and the table load runs on the null pointer, and the interpreter guards (`address < NULL_PAGE_END`) let the read through to `memcpy`. Guest memory starts at `0x40000` (`HOST_SYSTEM_MANAGED_MIN` in `memoryAddressSpace.inc`), so nothing below that can be guest data. A variant that compares the table pointer itself against `0x40000` in the compiled walker, right after `and rdi, r9` and before the range checks, uses `0x40000` as the interpreter threshold, and doesn't record those reads passes the test at both offsets: https://github.com/Nawid3333/KytyPS5/commit/df55cb78. I haven't seen offsets that large in the Astro Bot logs, so this is an edge case, not a blocker. <details><summary>Test (Fixture maps s2/s3 to user_data[0..1], user_data_base = 2)</summary> ```cpp void TestNullTablePointerReadsZero() { Fixture fixture; const auto memory = fixture.AddMemory(ResourceKind::ScalarAddress); const auto low = fixture.Emit(ValueOpcode::GetUserData, {Value(static_cast<ScalarReg>(2))}); const auto high = fixture.Emit(ValueOpcode::GetUserData, {Value(static_cast<ScalarReg>(3))}); const auto value = RawRead(fixture, Address(fixture, low, high), Value(0x18u), memory); LoadBuffer(fixture, {value, Value(0u), Value(16u), Value(0u)}); fixture.Plan(); const auto plan = ExtractResourcePlan(fixture.program); Check(plan.srt_code != nullptr, "user-data table reads were not compiled"); const std::array user_data{0u, 0u}; const SrtRuntime runtime{.user_data = user_data}; std::vector<std::pair<uint64_t, uint64_t>> ranges; SrtReadCapture capture(runtime, ranges); std::vector<uint32_t> flat; Check(SrtWalker(plan, capture.ObservedRuntime()).RefreshFlatBuffer(flat) && flat == std::vector<uint32_t>{0u} && ranges.empty(), "captured walk did not read a null table as zero"); uint32_t word = 1u; Check(SrtWalker(plan, runtime).Evaluate(plan.srt_reads[0].value, word) && word == 0u, "ordinary read did not read a null table as zero"); flat.clear(); Check(SrtWalker(plan, runtime).RefreshFlatBuffer(flat) && flat == std::vector<uint32_t>{0u}, "compiled walk did not read a null table as zero"); } ``` </details> AI use: Claude Code wrote the test and the variant, ran them on my machine and wrote this comment.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 22:24 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a796c68-9638-48f6-9b68-2a316c9251f6
📥 Commits

Reviewing files that changed from the base of the PR and between e28ca2b937 and 4d7110b43c.

📒 Files selected for processing: 2
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • tests/ScalarProvenanceTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 22:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1528#pullrequestreview-5540652269) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `6a796c68-9638-48f6-9b68-2a316c9251f6` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e28ca2b93742385e893bdc33466852b0f3968b97 and 4d7110b43c256c2c65a168743687888cdc39719c. </details> <details> <summary>📒 Files selected for processing: 2</summary> * `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` * `tests/ScalarProvenanceTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=49d10dc7-b8b5-47b2-ac86-53ae8fbd1c06 attempt=e8bd25c5-1066-4b14-bc29-aa5b931fcea1 batch=1/1 -->
@ -38,6 +47,9 @@ bool SrtReadCapture::ReadOrdinary(void* userdata, uint64_t address, std::span<ui
auto& capture = *static_cast<SrtReadCapture*>(userdata);
if (capture.m_source.read_memory != nullptr) {
if (!capture.m_source.read_memory(capture.m_source.userdata, address, values)) return false;
} else if (address < GUEST_MEMORY_MIN) {
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 22:24 UTC · original · edited 2026-10-15 22:31 UTC

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'ReadOrdinary|EvaluateRawRead|RefreshFlatBuffer|GUEST_MEMORY_MIN|CaptureRange|record.*range' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
sed -n '15,120p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
sed -n '675,735p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
sed -n '680,745p' tests/ScalarProvenanceTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 9485


🏁 Script executed:

set -eu
printf '%s\n' '--- changed files and focused diff ---'
git diff --no-ext-diff --unified=30 df5b9b92be7dfd463b47756b707d6d356a9f0550 4d7110b43c256c2c65a168743687888cdc39719c -- src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp tests/ScalarProvenanceTests.cpp
printf '%s\n' '--- generated compiled-walk guard ---'
sed -n '430,485p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
printf '%s\n' '--- EvaluateRawRead complete block ---'
sed -n '625,725p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
printf '%s\n' '--- RefreshFlatBuffer complete block ---'
sed -n '1080,1135p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
printf '%s\n' '--- relevant declarations and call sites ---'
rg -n -F -- 'EvaluateRawRead(' 'RefreshFlatBuffer(' 'ReadOrdinary(' 'ObservedRuntime(' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp src/graphics/shader/recompiler/ir/passes/SrtWalker.h

Repository: KytyPS5/KytyPS5

Length of output: 26395


Guard the table base before dispatching the captured read.

For base == 0 and an offset of at least 0x40000, EvaluateRawRead computes a final address that passes SrtReadCapture::ReadOrdinary's check. The callback then performs memcpy and records the range. This can fault on an unmapped host address or record an invalid specialization range.

The captured path does not use the compiled walker because ObservedRuntime installs ReadOrdinary. Add the base check before invoking the reader:

Suggested fix
 	if (reader != nullptr) {
+		if (base < GUEST_MEMORY_MIN) {
+			result = 0;
+			return true;
+		}
 		if (!reader(m_runtime.userdata, address, {&word, 1})) {
 			return false;
 		}

✅ Addressed in commit bd8f0da

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 22:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1528#discussion_r4288883277) · edited 2026-10-15 22:31 UTC **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash rg -n 'ReadOrdinary|EvaluateRawRead|RefreshFlatBuffer|GUEST_MEMORY_MIN|CaptureRange|record.*range' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp sed -n '15,120p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp sed -n '675,735p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp sed -n '680,745p' tests/ScalarProvenanceTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 9485 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- changed files and focused diff ---' git diff --no-ext-diff --unified=30 df5b9b92be7dfd463b47756b707d6d356a9f0550 4d7110b43c256c2c65a168743687888cdc39719c -- src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp tests/ScalarProvenanceTests.cpp printf '%s\n' '--- generated compiled-walk guard ---' sed -n '430,485p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp printf '%s\n' '--- EvaluateRawRead complete block ---' sed -n '625,725p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp printf '%s\n' '--- RefreshFlatBuffer complete block ---' sed -n '1080,1135p' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp printf '%s\n' '--- relevant declarations and call sites ---' rg -n -F -- 'EvaluateRawRead(' 'RefreshFlatBuffer(' 'ReadOrdinary(' 'ObservedRuntime(' src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp src/graphics/shader/recompiler/ir/passes/SrtWalker.h ``` Repository: KytyPS5/KytyPS5 Length of output: 26395 --- </details> **Guard the table base before dispatching the captured read.** For `base == 0` and an offset of at least `0x40000`, `EvaluateRawRead` computes a final address that passes `SrtReadCapture::ReadOrdinary`'s check. The callback then performs `memcpy` and records the range. This can fault on an unmapped host address or record an invalid specialization range. The captured path does not use the compiled walker because `ObservedRuntime` installs `ReadOrdinary`. Add the base check before invoking the reader: <details> <summary>Suggested fix</summary> ```diff if (reader != nullptr) { + if (base < GUEST_MEMORY_MIN) { + result = 0; + return true; + } if (!reader(m_runtime.userdata, address, {&word, 1})) { return false; } ``` </details> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:9edb7728190f11ce4464cedd --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit bd8f0da
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-16 18:21 UTC · original

The JIT part of this PR is on a crash path too, not only hardening: Star Wars: Galactic Racer (#1481, official build df5b9b9) crashes in code generated at runtime, at 0x100b1dac020, with rdi = 0. The bytes around the fault, 55 48 89 e5 49 83 f8 06 0f 82 2a 00 00 00 49 b9 fc ff ff ff ff ff 00 00 57 48 8b 7f 10 4c 21 cf | 44 8b 17 44 89 16 4c 89 12 48 89 4a 08 5f, are

push rbp; mov rbp, rsp; cmp r8, 6; jb failed; mov r9, 0x0000fffffffffffc
push rdi; mov rdi, [rdi + 0x10]; and rdi, r9
mov r10d, [rdi]            <- fault
mov [rsi], r10d; mov [rdx], r10; mov [rdx + 8], rcx; pop rdi

which is what CompileSrtWalker emits for a table whose pointer is user-data dwords 4-5, with one read at offset 0 (SrtWalker.cpp:447-484 on main, the same in df5b9b9). That pointer is 0 after the mask, and the compiled walk reads through it: its only pointer checks are for address wrap-around (first < 0, last > 0), so for a single read at offset 0 it emits none. With this PR (bd8f0dae) the compiled walk compares the table pointer with 0x40000 and falls back to the interpreted walk, which doesn't dereference such a pointer, so #1481 should get past this point as well (not tested, I don't have the game).

Written with Claude Code (AI): it decoded the bytes from the log and matched them to the source; I read this comment before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-16 18:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1528#issuecomment-6221976296) The JIT part of this PR is on a crash path too, not only hardening: Star Wars: Galactic Racer (#1481, official build df5b9b9) crashes in code generated at runtime, at `0x100b1dac020`, with `rdi = 0`. The bytes around the fault, `55 48 89 e5 49 83 f8 06 0f 82 2a 00 00 00 49 b9 fc ff ff ff ff ff 00 00 57 48 8b 7f 10 4c 21 cf | 44 8b 17 44 89 16 4c 89 12 48 89 4a 08 5f`, are ``` push rbp; mov rbp, rsp; cmp r8, 6; jb failed; mov r9, 0x0000fffffffffffc push rdi; mov rdi, [rdi + 0x10]; and rdi, r9 mov r10d, [rdi] <- fault mov [rsi], r10d; mov [rdx], r10; mov [rdx + 8], rcx; pop rdi ``` which is what `CompileSrtWalker` emits for a table whose pointer is user-data dwords 4-5, with one read at offset 0 (`SrtWalker.cpp:447-484` on main, the same in df5b9b9). That pointer is 0 after the mask, and the compiled walk reads through it: its only pointer checks are for address wrap-around (`first < 0`, `last > 0`), so for a single read at offset 0 it emits none. With this PR (bd8f0dae) the compiled walk compares the table pointer with `0x40000` and falls back to the interpreted walk, which doesn't dereference such a pointer, so #1481 should get past this point as well (not tested, I don't have the game). Written with Claude Code (AI): it decoded the bytes from the log and matched them to the source; I read this comment before posting it.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-21 17:13 UTC · original

A/B on current main, ASTRO BOT (PPSA21564, 01.007.000), Windows 11, RX 9070 XT. Both builds are main 4644c529 plus two lab commits of mine that play scripted gamepad input (the same in both), one of them with this PR's three commits cherry-picked unchanged (they still apply cleanly):

  • without this PR: exits after 12 s with Unhandled host exception: type=1 code=3221225477 pc=0x00007ffcbf6cc12a access=1 address=0x0000000000000058, right after the recompiler built a shader that loads an image descriptor through an address resource. The fault pc ends in the same …c12a as the ASTRO BOT reports #1623 and #1675 (address 0x18 there).
  • with this PR: runs until my 5-minute limit with no fatal error and no device loss. A second 4-minute run with screenshots reaches the opening scenes (the bots on the mothership at about 1:20, Astro crashed in the desert at about 3:30), 25-37 FPS on the overlay.

The same A/B on main 0cad4672 on 10-20 gave the same result (crash at 14 s without this PR, the full 5 minutes with it).

**@⁠Nawid3333** on GitHub · 2026-10-21 17:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1528#issuecomment-6321991182) A/B on current main, ASTRO BOT (PPSA21564, 01.007.000), Windows 11, RX 9070 XT. Both builds are main 4644c529 plus two lab commits of mine that play scripted gamepad input (the same in both), one of them with this PR's three commits cherry-picked unchanged (they still apply cleanly): - without this PR: exits after 12 s with `Unhandled host exception: type=1 code=3221225477 pc=0x00007ffcbf6cc12a access=1 address=0x0000000000000058`, right after the recompiler built a shader that loads an image descriptor through an address resource. The fault pc ends in the same `…c12a` as the ASTRO BOT reports #1623 and #1675 (address 0x18 there). - with this PR: runs until my 5-minute limit with no fatal error and no device loss. A second 4-minute run with screenshots reaches the opening scenes (the bots on the mothership at about 1:20, Astro crashed in the desert at about 3:30), 25-37 FPS on the overlay. The same A/B on main 0cad4672 on 10-20 gave the same result (crash at 14 s without this PR, the full 5 minutes with it).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.