shader: read scalar loads through a null SRT pointer as zero #1380
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!1380
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1380/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?
@HamsterCL on GitHub · 2026-10-10 18:19 UTC · original
HamsterCL:fix/srt-null-scalar-reads→main· +54 −1 · 2 files · 1 commits · closed without mergingSummary
Scalar loads through a null SRT pointer now read as zero on the ordinary (non-strict) path instead of faulting the emulator. Strict/clean (specialization) reads are unchanged and still fail on unreadable addresses.
Problem
Astro Bot (PPSA21567) crashed with an access violation at address 0x18 in
SrtReadCapture::ReadOrdinary/SrtWalker::EvaluateRawRead(register rdx=0x18). The SRT walker evaluates scalar loads on branches the shader does not execute. One of them goes through a pointer read from a table that is all zeroes, so the address is base 0 plus offset 0x18, and the walker did a direct hostmemcpyfrom that address.Change
In
src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp:SrtReadCapture::ReadOrdinary, when noread_memoryis installed: addresses below 0x40000 read as zero; empty spans and out-of-range address/size combinations return false.SrtWalker::EvaluateRawRead, no-reader fallback for scalar loads: addresses below 0x40000 read as zero.read_specialization_memory) are untouched.New test
TestNullScalarPointerReadsZeroInOrdinaryPathintests/ScalarProvenanceTests.cppcovers the no-reader path, the ordinary capture path, and checks that the strict path still returns false. It segfaults without the fix and passes with it.Relation to #1365 and #1374
Both open PRs address the same symptom, and the approaches overlap.
SrtWalker.cpp, with a test.read_memoryreader inpipelineCache.cppviaMemory::TryReadBackingthat returns zeroes for unmapped addresses.What this PR adds: it covers both
ReadOrdinary(the capture path) and theEvaluateRawReadfallback, it keeps strict reads unchanged, and it includes a test for all three paths. Happy to close this if one of those is preferred.Testing
scalar_provenance,resource_tracking,resource_materialization,shader_recompiler_computeall pass (Release, clang-cl).--amd-cpugets past the crash and ran for about 160 s on an Intel Core i5-12400F + RTX 3060 Ti (Windows 11). This only shows the crash is gone, not that the game works. Without--amd-cpuon Intel it crashes elsewhere, in SceSndzAudioOutMain (known, see #687 / #1081).AI use
Claude Code was used for the investigation (symbolizing the host crash and tracing it to the SRT walker), for the implementation and for the new test. I reviewed the diff myself. The four test binaries above and the Astro Bot run were executed on my machine. I did not test gameplay.
@coderabbitai[bot] on GitHub · 2026-10-10 18:23 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
1696b456-221a-4817-a130-971efc10f165📥 Commits
Reviewing files that changed from the base of the PR and between
1cfb9522a3and1c4b66c994.📒 Files selected for processing (2)
src/graphics/shader/recompiler/ir/passes/SrtWalker.cpptests/ScalarProvenanceTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
The read paths now reject empty spans and addresses outside the 48-bit guest-address limit. Without a memory reader, valid addresses below
0x40000return zero-filled data for ordinary reads and scalar raw reads. Higher addresses retain direct host-memory copies. Vector reads without a reader still fail. Tests cover null-base scalar reads across the affected paths.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
1c4b6The reported null-pointer scalar read is handled by the ordinary path, and neither review concern establishes a reason to delay merging after normal checks.
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.@Nmzik on GitHub · 2026-10-10 19:54 UTC · original
Duplicate
Pull request closed