GPU: reject corrupted successful and refused shader-cache entries #3098
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3098
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3098"
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?
@yefan911 on GitHub · 2026-11-26 07:52 UTC · original
yefan911:fix/shader-refusal-cache-integrity→main· +141 −9 · 1 files · 4 commits · openFollow-up to #1094 and the triage request to protect successful translations as well as refusals. A same-length edit to a serialized successful entry can otherwise return changed DXIL or metadata as a cache hit.
Both successful (
VSH2) and refused (VSF3) shader-cache entries now carry a trailing BLAKE3 digest covering the complete serialized payload, including the marker. Decode checks the digest before interpreting fields, retains its structural checks, and treats damaged entries as cache misses so they are translated again. Refusal text must still be valid UTF-8.The checksum belongs to this serialization layer:
victory_pipeline::Cachestores opaque converter output and returns its raw path to callers. This keeps the cache API and atomic publication unchanged. It detects accidental damage; it does not establish how damage occurred or claim that VIctory's atomic rename normally publishes partial files.The build fingerprint includes
shader_cache.rs, so the encoding change selects a fresh cache namespace. Existing translated entries are rebuilt once. Successful entries gain a 32-byte digest, and cache hits verify the complete payload. No performance or gameplay improvement is claimed.The all-entry integrity implementation is contributed by XeNS1, incorporated from yefan911/VIctory#1 while preserving commit
71de96199ef60e0bead2c0b19a778d8b76c274b4and its authorship.Validation on Windows x86-64 / Rust 1.98.1:
shader_cache.rsand depends on the actualvictory-shaderandvictory-pipelinecrates, with no behavior stubs or GPU host feature. All seven cache-module tests pass, including mutation of every byte, truncation, appended data, correctly checksummed malformed fields, and on-disk corruption followed by retranslation and a cache hit.cargo test -p victory-pipeline --locked: eight tests pass.191 files ok) pass.cargo test -p victory-gpu --lib shader_cache:: --locked -- --test-threads=1builds the full GPU test binary successfully, but that binary exits before starting the test harness withSTATUS_ACCESS_VIOLATION(0xc0000005) on this machine. Full GPU-binary test execution is therefore still unverified here; the isolated module results above are reported separately.All new fixtures are synthetic. No game files, game assets, retail checks, or gameplay execution used. No dependencies or CI files changed. The follow-up's existing Windows CI approval was granted; this description does not claim that run has passed.
AI-assisted: GPT-6.1 Sol; community contribution retains its own attribution.
@Dukestar69 on GitHub · 2026-11-26 08:11 UTC · original · approved these changes
Verified against
origin/main(63bcca4):cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1: 4/4 passed (including truncated refusal retranslation and same-length blake3 corruption rejection).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Adding a length prefix and blake3 digest under the
VSF2refusal tag cleanly turns torn/corrupted cached refusal entries into cache misses.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Marvisak on GitHub · 2026-11-26 08:24 UTC · original
Automated triage for the maintainers.
Needs work. The encoding change in
crates/victory-gpu/src/shader_cache.rs(encode/decode,VSHEtoVSF2with a length and a BLAKE3 digest) reads correctly, and CI passes. The problem is that it guards against something that does not happen through this code, and it does nothing for the entries that matter more:victory_pipeline::Cache, which writes to a temp file and renames it (crates/victory-pipeline/src/cache.rs, "Write-then-rename so readers never see partial output"). A torn refusal entry can only come from damage outside VIctory.VSH1) get no digest. A damagedVSH1entry that still parses would hand the GPU wrong DXIL, which is a far worse result than a short refusal reason.What would change the verdict: a real path where a refusal entry ends up truncated (a run log or a reproduction), or an integrity check that covers every entry. That check probably belongs in
victory_pipeline::Cacherather than in one entry kind. Thetranslateclosure reformat inhost_shaderis unrelated to the fix and can be dropped.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 08:39 UTC · original · reviewed
Verified locally on Windows 11:
cargo test -p victory-gpu --lib -- shader_cache::(default and--all-features): 4/4 passedcargo clippy -p victory-gpu --all-targets -- -D warnings(default and--all-features): cleancargo xtask policy: 191 files okThe
VSF2encode/decode implementation itself is clean and memory-safe:Reader::takechecks bounds viasplit_at_checkedbefore allocating, and truncation at any offset, trailing garbage (!r.0.is_empty()), same-length bit flips, invalid UTF-8, and legacyVSHEfiles are all rejected cleanly into cache misses.Two small observations for maintainers / polish:
victory-pipeline'sCache::get_or_convertalready publishes entries via write-temp-then-rename (though withoutsync_all, so power-loss truncation or external disk corruption is still possible). Adding a 32-byte BLAKE3 digest only to refusal entries whileVSH1shader entries rely solely on length framing +r.0.is_empty()is slightly asymmetric — if maintainers prefer minimal format complexity, framing refusals withr.list()?+r.0.is_empty()already matchesVSH1's truncation guarantees, whereas keeping the BLAKE3 check here is cheap and harmless.decode, bindinglet tag = r.take(4)?;once avoids resettingr = Reader(bytes)and checking the prefix twice; andentries_round_trip_and_reject_damagecould also cover trailing extra bytes on aVSF2entry (matching theVSH1trailing-byte test right above it).@XeNS1 on GitHub · 2026-11-26 08:53 UTC · original
I prepared the requested all-entry integrity follow-up against the existing author branch: https://github.com/yefan911/VIctory/pull/1 (commit
71de96199e). Both original yefan911 commits are preserved; no competing upstream PR was opened.The new tests reproduce a successful cache entry returning changed DXIL as a hit, and a single-byte edit changing PS to VS. A common trailing BLAKE3 digest now covers the whole serialized success/refusal entry before any fields are decoded. Three new tests cover all single-byte edits, truncation/append, correctly checksummed malformed fields, and actual disk corruption followed by a miss/retranslation/hit. No claim of a naturally torn atomic write; this addresses the broader integrity option in triage.
Native Linux: the harness imports the actual shader_cache.rs and actual victory-shader/victory-pipeline crates, with no behavior stubs. All 7 module tests and 7 pipeline tests pass; strict all-target Clippy, rustfmt and asset policy pass. The two new success regressions fail on
edd8d503(4 pass / 2 fail), and pass with the follow-up (7 / 0). No game files or GPU execution used. The new encoding changes the existing source fingerprint, so old translated entries are rebuilt once.The author's CI run requires their approval.
cargo check --locked --offline --target x86_64-pc-windows-msvc -p victory-gpu --lib --tests --all-features --features blake3/purealso passes with Rust 1.100; its only two warnings are unchanged Atomic::fetch_update deprecations in object.rs. This is a Windows-target compile check; Windows execution and GPU validation are not claimed.AI-assisted: OpenAI Codex.
GPU: reject truncated or corrupted shader refusal entriesto GPU: reject corrupted successful and refused shader-cache entriesView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.