shader: read null SRT pointers as zero in raw scalar reads #1374
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!1374
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1374/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?
@ReverendOzmund on GitHub · 2026-10-10 15:25 UTC · original
ReverendOzmund:fix/srt-null-scalar-read→main· +54 −0 · 2 files · 2 commits · closed without mergingfixes a host segfault in the shader recompiler
PPSA28038 boots, plays the intro videos, then the emulator segfaults right as the menu narration prompt comes up. tracked it with the linker map to
SrtWalker::EvaluateRawRead: when theres no memory reader (pipeline cache path) it memcpys straight from the address, and the game had a null SRT pointer at that point so it read from 0this makes reads below 64 KiB return 0 instead. nothing can ever be mapped there on linux or windows so it could only ever crash, and a zero descriptor ends up as the null buffer which is how empty vector buffers already get handled. open to a different approach if returning false or wiring up a reader there is preferred, first version returned false but that just made MaterializeResources hit its EXIT_IF instead
testing
TestNullScalarAddressWithoutReaderReadsZeroto ScalarProvenanceTests, it segfaults without the fix and passes with itscalar resource reads overlap a shader buffer writein descriptors.cpp) which ill report separatelyai
used claude to track down the crash and write the fix + test. i ran the test and the game myself before submitting

@coderabbitai[bot] on GitHub · 2026-10-10 15:28 UTC · original · edited 2026-10-10 15:43 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
950ffbfc-018f-4b77-ad53-69049ba3524b📥 Commits
Reviewing files that changed from the base of the PR and between
05dc968a88andfd4ce64dee.📒 Files selected for processing (2)
src/graphics/shader/recompiler/ir/passes/SrtWalker.cpptests/ScalarProvenanceTests.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
When no reader callback is available, ordinary and raw reads below
0x10000return zero. Ordinary reads do not record a guest memory range. Tests cover a scalar read at address zero and a two-word capture read at address0x20.Priority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
fd4ceThe null-pointer read fix appears mergeable after normal checks; no outstanding issue is identified in the supplied evidence.
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.@ -564,0 +582,4 @@if (address < NullPageLimit) {result = 0u;return true;}@coderabbitai[bot] on GitHub · 2026-10-10 15:28 UTC · original · edited 2026-10-10 15:44 UTC
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5429
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 28572
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42135
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8381
Cover the capture wrapper’s direct-read fallback.
The pipeline-cache runtime sets
read_specialization_memorybut leavesread_memoryunset. When capture is enabled,MaterializeResourcespassescapture.ObservedRuntime()toSrtWalker.ReadOrdinarythen directly copies from the SRT address, so the null-page guard inEvaluateRawReadis bypassed. A null or near-null scalar SRT address can fault the host.Apply the same null-page behavior in
ReadOrdinarybeforememcpy.🐛 Suggested fix
✅ Addressed in commit
fd4ce64@coderabbitai[bot] on GitHub · 2026-10-10 15:28 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
8c06743b-cbd3-4e11-8bb4-1ed8f0da7672📥 Commits
Reviewing files that changed from the base of the PR and between
307fdcf7adand05dc968a88.📒 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.
@ -564,0 +582,4 @@if (address < NullPageLimit) {result = 0u;return true;}@ReverendOzmund on GitHub · 2026-10-10 15:42 UTC · original
good catch, ReadOrdinary had the same raw memcpy. moved NullPageLimit up so both use it and ReadOrdinary now zero fills without recording a range since nothing was actually read. added TestNullScalarAddressCaptureReadsZero, segfaults without the guard and passes with it
@ -564,0 +582,4 @@if (address < NullPageLimit) {result = 0u;return true;}@coderabbitai[bot] on GitHub · 2026-10-10 15:44 UTC · original
@ReverendOzmund, thanks for the fix.ReadOrdinarynow uses the sharedNullPageLimitguard and returns zeros without recording a guest memory range. The regression test covers the capture-wrapper path that bypassed the original guard.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@Nmzik on GitHub · 2026-10-10 19:53 UTC · original
Duplicate
Pull request closed