Shader capture reads an inaccessible direct-root scalar load skipped by a known branch #8272
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-20T08:09:34Z.
Status, 2026-10-21 UTC
Closed after #8295 merged. The upstream correction now covers the known-branch flat-load reachability gap. This records the merge and issue closure; it is not a fresh current-main runtime test or title claim. The original reproducer, proposed fix and validation below retain their recorded source pins.
Summary
Main at
7d876ad3ba9571787faa44759b9ac692e77c3eecrejects a synthetic compute program during resource capture when a scalar branch skips a load through an inaccessible, nonzero direct user-data pointer.Test-only reproducer on our fork. It extends the existing
NestedRequest/verifyGuardedNullPointersfixture with a pointer supplied in user SGPRs s2:s3 and moved to s10:s11. The scalar value is used by an output store.The program initializes s12, loads a condition from valid memory, compares it with zero, and executes
s_cbranch_scc1at pc 0x28. With condition zero it jumps to pc 0x38, skippings_load_dword s12, s[10:11], 0at pc 0x2c and its wait. Decoder assertions verify the moves, compare and branch target.Reproduction and result
Build
agc_shader_memory_tests, then run:Three consecutive Windows 11 Enterprise 26200 / WinLibs GCC 15.2.0 Release runs, each under 2 seconds for the test:
guest memory is not readableguest memory is not readable ... +0x4; expected to avoid this dereferenceThe inaccessible address is a test-owned
MEM_RESERVE/PAGE_NOACCESSallocation. The fixture retains its region vectors and user-data array throughout their use. This is CPU capture/compiler validation; no GPU execution or title result is claimed.Source and expected behavior
AMD RDNA 2 ISA reference, revision 2020-11-30, sections 12.3-12.5 (printed pages 111, 123-124), specifies the move, comparison and conditional PC update used here. The taken branch jumps over the scalar load; this does not rely on EXEC suppressing scalar memory instructions.
In
SrtDescriptorEvaluation.cpp,evaluateRuntimeSourcesevaluates every flattened SRT slot after its descriptor-source walk. The fixture checks that this load's handle is not classified asLoadedFromMemory; the existing nested-pointer poison handling therefore does not cover it.Related: #479/#759 cover guarded nested reads. #5384 was closed because #5573 fixed the reused fused-program lifetime behind #5099. This fixture builds its own program and does not exercise fusion. #7891 changes branch waits and descriptor-source selection; it does not establish coverage of this scalar-value load.
A correction needs to preserve reachability for these flat reads, or retain their load on the shader execution path, while preserving explicit failure for an invalid read that actually executes. The reproducer commit remains deliberately failing on unmodified main.
Proposed correction and validation
Experimental fix on our fork, rebased onto main
5e7c618699564093531727fbe2feaea5952a5ba1:At pre-rebase head
a0d29666f5352ca35f8205ae2d22f9daf77e277eon main587bb343e8baf0f9c62bdb04c9dab5eb4b938dc9, the selected targets compiled and 12 final CPU test executions passed: three runs each of shader memory, SRT read patching, shader disk cache and cache-file reading. The new fixture covers original/decoded plans, direct tape execution, compact and IR evaluation, unreadable guards, and an unconditional repeated load. Nonempty flat-slot lists now participate in the existing cache round-trip equality test. SPIR-V Tools is enabled.Cppcheck and clang-tidy completed for all six changed translation units without parser errors. Findings were reviewed: no new production finding; a new fixed-array address-invalidation warning is a false positive, and existing advisories remain recorded.
All nine changed files are SHA-256-identical after the clean rebase. The test results above retain their original pins. The fork advanced to 8a8f2b157941deb4582808ecf926ff429888b76a with a direct-root device regression and corrected expectations in the existing GPU fixture. The full runtime build and twelve candidate GPU test executions across NVIDIA and AMD passed. The paired test-only control on main
5e7c618699564093531727fbe2feaea5952a5ba1is complete: on each GPU the existing suite passed three times, and the new regression failed three times at the skipped inaccessible load after its positive controls succeeded. The fix passed both suites three times on each GPU. Across all 24 executions, adapters and actual Khronos device-layer insertion were verified; zero Vulkan validation errors, warnings or VUIDs. The six expected baseline failures demonstrate the bug. Title validation remains pending. Cppcheck and clang-tidy also completed for the new GPU fixture without parser/configuration errors: clang-tidy had no diagnostics, and the single Cppcheck diagnostic concerns an unchanged fixedstd::arrayassignment, which cannot invalidate its storage address.Upstream implementation: #8295 by @mazen320 adapts the published fix. Its six production files are byte-identical to the original fork implementation; the CPU fixture moves one control earlier. GPU fixtures and scoped validation are shared in this PR comment. Further validation will be coordinated there.
AI-assisted: yes.