shader: no raw guest dereference in the SRT walker and the read capture #1102
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1102
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1102/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@wuboo on GitHub · 2026-10-06 07:34 UTC · original
wuboo:fix/srt-checked-reads→main· +139 −27 · 4 files · 5 commits · closed without mergingshader: no raw guest dereference in the SRT walker and the read capture
Problem
In the production configuration the pipeline cache builds
SrtRuntimewith onlyread_specialization_memory = ReadShaderGuestMemory(a bounds-checked reader);read_memoryis null.Two places treated "no ordinary reader" as "the address can be dereferenced directly":
SrtWalker::EvaluateRawReaddidmemcpyfrom the guest address when neither reader was set.CaptureOrdinaryRead(the read capture used while refreshing a plan with captured specialization reads)did
memcpyfrom the guest address whenread_memorywas null. With the production runtime this path isalways taken.
A scalar table the guest never set up (null or stale base, e.g. a DispatchIndirect shader whose
wave-dependent path is not executed) therefore faults the host in
memmoveinstead of failing the refresh.Seen with Astro Bot on macOS: host access violation at null+0x18 in
CaptureOrdinaryRead.Changes (3 commits)
SrtWalker::EvaluateRawReadfalls back to the checked specialization reader when no ordinary reader isset.
RefreshFlatBuffertolerates failed reads in blocks that were entered only because their branchcondition could not be evaluated (the path is chosen per wave and may not run on the guest). Blocks
reached through evaluated conditions must still resolve.
CaptureOrdinaryReadusesread_memoryif set, otherwise the checkedreader, otherwise the read fails;
EvaluateRawReadlikewise (vector reads and reads without any reader fail).No behaviour change when an ordinary reader is supplied.
Tests
resource_materialization: mapped SRT reads go through the checked reader (read counter > 0); a null tableis rejected by the checked reader; a read with no reader at all fails instead of faulting.
resource_tracking: the guarded scalar descriptor test runs with only the checked reader.resource_materializationaborts,resource_trackingsegfaults)and pass with them.
cteston macOS (50 tests): identical to a freshorigin/main(cdb64bfd) build: 34 pass, 16 skipped(no Vulkan loader in the test environment), 0 failures.
Caveats
MaterializeResourcesasfatal (
EXIT_IFinProgramCache::Get) report a materialization failure instead of a host fault.@coderabbitai[bot] on GitHub · 2026-10-06 07:43 UTC · original · edited 2026-10-06 08:14 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
f567e6b5-43f8-4d71-a4ae-83a723a60fba📥 Commits
Reviewing files that changed from the base of the PR and between
7e40b02c8fandeda7620666.📒 Files selected for processing (2)
src/graphics/shader/recompiler/ir/passes/SrtWalker.cpptests/ResourceTrackingTests.cpp🚧 Files skipped from review as they are similar to previous changes (2)
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
Walkthrough
Resource materialization and raw SRT reads no longer dereference guest addresses when a checked reader is unavailable or fails. They use the specialization-memory reader when the ordinary reader is unavailable. Flat-buffer traversal tracks definite and speculative paths, and read failures abort refresh only on definite paths. Tests cover checked readers, failed reads, cache rematerialization, and traversal certainty.
Priority: ⬇️ Low
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
eda76The reviewed changes have no identified issue requiring a fix before merge.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-06 07:43 UTC · original · edited 2026-10-06 08:04 UTC
On
src/graphics/shader/recompiler/ir/passes/SrtWalker.cppline 990 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep single-successor edges definite.
If a definite block has one successor, this line marks that mandatory successor speculative. A failed SRT read in the successor is then ignored, and
RefreshFlatBuffercan return success with a zero flattened slot. Propagate the current certainty when there is only one successor. Mark successors speculative only when selection is unresolved.🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4865
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 25282
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12239
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14958
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4721
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 685
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5094
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3823
Evaluate predicates that do not need specialization memory.
MaterializeResourcesaccepts a runtime withread_memorybut no specialization reader when the plan does not otherwise require specialization memory. The current renderer call sites supplyReadShaderGuestMemory. For a reader-only runtime,RefreshFlatBufferskips a resolvable user-data predicate and marks both successors speculative. A failed ordinary read on the selected successor can then be ignored, leaving its flattened slot at zero while refresh succeeds. Evaluate the predicate through the clean evaluator; it can resolve user-data-only conditions and rejects memory reads when no checked reader is available.🐛 Suggested fix
✅ Addressed in commits
0e4a876toeda7620@coderabbitai[bot] on GitHub · 2026-10-06 07:43 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
1e67a0b0-f49e-4358-8019-3642e40a77fe📥 Commits
Reviewing files that changed from the base of the PR and between
cdb64bfd4fand7e40b02c8f.📒 Files selected for processing (4)
src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/SrtWalker.cpptests/ResourceMaterializationTests.cpptests/ResourceTrackingTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@wuboo on GitHub · 2026-10-06 08:04 UTC · original
Single-successor edges (Major): Fixed in
0e4a876a— a block that is certain to run now passes that certainty to its only successor, so a failed SRT read there fails the refresh. Speculative is kept only for undecided branches (two or more successors). Regression test ineda76206(fails on the previous code)."Evaluate predicates that do not need specialization memory" (Minor): I'd rather leave this out of this PR. Predicates are evaluated only when specialization memory is available, exactly as before the PR, and changing that alters which blocks count as certain for existing shaders. It is a behavior change independent of the checked-read work, so it fits better in a separate PR with its own test.
Pull request closed