Shaders: fix 4 DXIL validator bugs and add synthetic container/validator tests #1202

Closed
github-bot wants to merge 2 commits from gh-pr/1202/head into gh-pr/1202/base
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 16:24 UTC · original
geiyiliyabumo:test/shader-container-validator → main · +765 −25 · 2 files · 2 commits · closed without merging

Summary

Closes #1049

Full verification details and change notes are documented in #1049 (commit 9ffb7a1, based on main ffe310e).

 crates/victory-shader/src/emit/container.rs | 309 ++++++++++++++++++++
 crates/victory-shader/src/emit/validator.rs | 427 ++++++++++++++++++++++++++--
 2 files changed, 719 insertions(+), 17 deletions(-)

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check on edited files: PASS
  • cargo xtask policy: PASS (zero game files/data)
  • cargo clippy --all-targets --locked -- -D warnings (default + --features diagnostics where applicable): PASS
  • Targeted & crate unit/GPU tests: PASS

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 16:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1202) `geiyiliyabumo:test/shader-container-validator` → `main` · +765 −25 · 2 files · 2 commits · closed without merging ### Summary Closes #1049 Full verification details and change notes are documented in #1049 (commit `9ffb7a1`, based on `main` `ffe310e`). ```text crates/victory-shader/src/emit/container.rs | 309 ++++++++++++++++++++ crates/victory-shader/src/emit/validator.rs | 427 ++++++++++++++++++++++++++-- 2 files changed, 719 insertions(+), 17 deletions(-) ``` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check` on edited files: **PASS** - `cargo xtask policy`: **PASS** (zero game files/data) - `cargo clippy --all-targets --locked -- -D warnings` (default + `--features diagnostics` where applicable): **PASS** - Targeted & crate unit/GPU tests: **PASS** *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:23:28 +00:00
github-bot closed this pull request 2026-11-26 04:23:28 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 16:56 UTC · original

Tested Validator against the Windows SDK dxil.dll and found two additional live-DLL edge cases worth folding in alongside the COM/module lifetime fixes:

  1. STATUS_ACCESS_VIOLATION (0xc0000005) inside dxil.dll on truncated "DXBC..." blobs: IDxcValidator::Validate trusts DxilContainerHeader::ContainerSizeInBytes and PartCount at offsets 24/28 before checking IDxcBlob::GetBufferSize(), reading out of bounds on truncated or corrupt DXBC headers. Running if container.starts_with(b"DXBC") { crate::dxbc::Container::parse(container).map_err(|e| e.to_string())?; } up front catches malformed containers in safe Rust without affecting non-DXBC unit-test stubs.
  2. Trailing NUL in Validator::load error strings: String::from_utf16_lossy(&name) includes the appended 0 terminator ("cannot load ...\0"). Encoding with OsStrExt::encode_wide().chain([0]) and formatting target.to_string_lossy() keeps both non-UTF-8 paths and error strings clean.

Also verified container::hash in-place signing byte-for-byte against dxil.dll across all 64 len % 64 padding remainders (including the 55/56 two-block split). Reference commit: github.com/fuzeofficlal/VIctory@6a82a194cf

**@⁠fuzeofficlal** on GitHub · 2026-11-24 16:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1202#issuecomment-7138431797) Tested `Validator` against the Windows SDK `dxil.dll` and found two additional live-DLL edge cases worth folding in alongside the COM/module lifetime fixes: 1. **`STATUS_ACCESS_VIOLATION` (`0xc0000005`) inside `dxil.dll` on truncated `"DXBC..."` blobs**: `IDxcValidator::Validate` trusts `DxilContainerHeader::ContainerSizeInBytes` and `PartCount` at offsets 24/28 before checking `IDxcBlob::GetBufferSize()`, reading out of bounds on truncated or corrupt `DXBC` headers. Running `if container.starts_with(b"DXBC") { crate::dxbc::Container::parse(container).map_err(|e| e.to_string())?; }` up front catches malformed containers in safe Rust without affecting non-`DXBC` unit-test stubs. 2. **Trailing NUL in `Validator::load` error strings**: `String::from_utf16_lossy(&name)` includes the appended `0` terminator (`"cannot load ...\0"`). Encoding with `OsStrExt::encode_wide().chain([0])` and formatting `target.to_string_lossy()` keeps both non-UTF-8 paths and error strings clean. Also verified `container::hash` in-place signing byte-for-byte against `dxil.dll` across all 64 `len % 64` padding remainders (including the 55/56 two-block split). Reference commit: https://github.com/fuzeofficlal/VIctory/commit/6a82a194cf1bdc045b8f74dce450a59be9dfadbf
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:15 UTC · original

Thanks @⁠fuzeofficlal for the live \dxil.dll\ edge-case review!

Folded both fixes into this PR:

  1. Pre-validate containers starting with \"DXBC"\ via \crate::dxbc::Container::parse(container)\ before invoking \IDxcValidator::Validate, catching truncated/corrupt DXBC headers in safe Rust instead of triggering \␀xc0000005\ inside \dxil.dll\ while leaving non-DXBC unit-test stubs unaffected.
  2. Encode the DLL path via \OsStrExt::encode_wide().chain([0])\ and format \ arget.to_string_lossy()\ so \Validator::load\ error strings no longer include a trailing NUL.

Added regression tests for both (\load_error_has_no_trailing_nul, \ runcated_dxbc_container_is_rejected_before_calling_dxil). Re-verified \cargo test -p victory-shader --lib emit::validator\ (11/11 passed), \cargo clippy -p victory-shader --all-targets -- -D warnings, and \cargo xtask policy.

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1202#issuecomment-7138931303) Thanks @⁠fuzeofficlal for the live \dxil.dll\ edge-case review! Folded both fixes into this PR: 1. Pre-validate containers starting with \"DXBC"\ via \crate::dxbc::Container::parse(container)\ before invoking \IDxcValidator::Validate\, catching truncated/corrupt DXBC headers in safe Rust instead of triggering \␀xc0000005\ inside \dxil.dll\ while leaving non-DXBC unit-test stubs unaffected. 2. Encode the DLL path via \OsStrExt::encode_wide().chain([0])\ and format \ arget.to_string_lossy()\ so \Validator::load\ error strings no longer include a trailing NUL. Added regression tests for both (\load_error_has_no_trailing_nul\, \ runcated_dxbc_container_is_rejected_before_calling_dxil\). Re-verified \cargo test -p victory-shader --lib emit::validator\ (11/11 passed), \cargo clippy -p victory-shader --all-targets -- -D warnings\, and \cargo xtask policy\. *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 18:00 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 9ffb7a1: cargo test -p victory-shader passes, 137 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 18:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1202#issuecomment-7140015245) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 9ffb7a1: `cargo test -p victory-shader` passes, 137 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:34 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #477. The same validator fixes as #477 (GetStatus, empty error blob, FreeLibrary, NUL in the message) at twice the size, plus container tests that pin current output; its Psv test literal lacks the gs field main added, so it does not compile on main.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1202#issuecomment-7148660070) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #477. The same validator fixes as #477 (GetStatus, empty error blob, FreeLibrary, NUL in the message) at twice the size, plus container tests that pin current output; its Psv test literal lacks the gs field main added, so it does not compile on main. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1202
No description provided.