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

Open
opened 2026-11-26 04:18:20 +00:00 by github-bot · 3 comments
Owner

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

Summary

Fixes 4 real defects in crates/victory-shader/src/emit/validator.rs (previously 0 tests) and adds 17 deterministic synthetic unit tests across validator.rs (0 -> 9 tests) and crates/victory-shader/src/emit/container.rs (1 -> 9 tests).

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/shader-container-validator
  • Commit: geiyiliyabumo/VIctory@9ffb7a1 (based on main ffe310e)

Changes

  • crates/victory-shader/src/emit/validator.rs:
    • Fixed false success when GetStatus fails.
    • Fixed unsafe handling of empty diagnostic buffers (no longer dereferences pointer when length is 0).
    • Fixed DLL reference leaks on validator creation failure and on Drop (releasing COM validator before freeing the module).
    • Added 9 synthetic tests using in-memory COM stubs covering all lifecycle and error paths.
  • crates/victory-shader/src/emit/container.rs:
    • Audited signature/PSV encoding, container headers/chunk offsets, and retail-hash padding; added 8 synthetic tests (9 total).

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: PASS (0 warnings)
  • cargo test -p victory-shader --locked -- container:: (9/9 PASS) & -- validator:: (9/9 PASS)

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 15:16 UTC · [original](https://github.com/Marvisak/VIctory/issues/1049) ### Summary Fixes 4 real defects in `crates/victory-shader/src/emit/validator.rs` (previously 0 tests) and adds 17 deterministic synthetic unit tests across `validator.rs` (0 -> 9 tests) and `crates/victory-shader/src/emit/container.rs` (1 -> 9 tests). Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/shader-container-validator` - **Commit**: `geiyiliyabumo/VIctory@9ffb7a1` (based on `main` `ffe310e`) ### Changes - **`crates/victory-shader/src/emit/validator.rs`**: - Fixed false success when `GetStatus` fails. - Fixed unsafe handling of empty diagnostic buffers (no longer dereferences pointer when length is 0). - Fixed DLL reference leaks on validator creation failure and on `Drop` (releasing COM validator before freeing the module). - Added 9 synthetic tests using in-memory COM stubs covering all lifecycle and error paths. - **`crates/victory-shader/src/emit/container.rs`**: - Audited signature/PSV encoding, container headers/chunk offsets, and retail-hash padding; added 8 synthetic tests (9 total). ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: **PASS** (0 warnings) - `cargo test -p victory-shader --locked -- container::` (**9/9 PASS**) & `-- validator::` (**9/9 PASS**) *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:20 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:54 UTC · original · edited 2026-11-25 09:58 UTC

Automated triage for the maintainers.

Confirmed on main (940d32f) in crates/victory-shader/src/emit/validator.rs: Validator::validate ignores the HRESULT of GetStatus, so if that call fails status stays 0 and the container is reported valid; it builds a slice with std::slice::from_raw_parts from the error blob's pointer without checking for a null pointer of length 0; and Validator::load never frees the dxil.dll module (not on a failed DxcCreateInstance, nor in Drop). All three only affect the offline validator path, not the title's run.

Open PR #477 ("fix DXIL validator UB on null error blobs, unchecked GetStatus, and COM/DLL handle leaks", also in bundle #1511) covers the same three defects, so review can continue there. The fork branch (9ffb7a1) is far behind main; its container.rs / validator.rs tests would need a rebase and a PR of their own (PRs are open to everyone).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:54 UTC · [original](https://github.com/Marvisak/VIctory/issues/1049#issuecomment-7155291842) · edited 2026-11-25 09:58 UTC <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-25T09:38:00Z at=2026-11-25T09:50:38Z --> Automated triage for the maintainers. Confirmed on `main` (940d32f) in `crates/victory-shader/src/emit/validator.rs`: `Validator::validate` ignores the HRESULT of `GetStatus`, so if that call fails `status` stays 0 and the container is reported valid; it builds a slice with `std::slice::from_raw_parts` from the error blob's pointer without checking for a null pointer of length 0; and `Validator::load` never frees the `dxil.dll` module (not on a failed `DxcCreateInstance`, nor in `Drop`). All three only affect the offline validator path, not the title's run. Open PR #477 ("fix DXIL validator UB on null error blobs, unchecked GetStatus, and COM/DLL handle leaks", also in bundle #1511) covers the same three defects, so review can continue there. The fork branch (`9ffb7a1`) is far behind `main`; its `container.rs` / `validator.rs` tests would need a rebase and a PR of their own (PRs are open to everyone). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:35 UTC · original

Validated the fork branch on Windows 11 Pro 26200 (Intel Core i5-14600K, RTX 5060 Ti, driver 621.24, Rust 1.98.1 MSVC), commit 57d00fd: cargo test -p victory-shader --locked --no-fail-fast -> 139 passed, 0 failed, 1 ignored. Synthetic tests only, no game files.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:35 UTC · [original](https://github.com/Marvisak/VIctory/issues/1049#issuecomment-7158528891) Validated the fork branch on Windows 11 Pro 26200 (Intel Core i5-14600K, RTX 5060 Ti, driver 621.24, Rust 1.98.1 MSVC), commit `57d00fd`: `cargo test -p victory-shader --locked --no-fail-fast` -> **139 passed, 0 failed, 1 ignored**. Synthetic tests only, no game files.
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:38 UTC · original

Addendum: this branch is far behind current main (the victory-shader delta is 34 files, ~16.5k lines), so the run above is the branch as-is on its old base; it needs a rebase before a clean cherry-pick.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:38 UTC · [original](https://github.com/Marvisak/VIctory/issues/1049#issuecomment-7158593444) Addendum: this branch is far behind current main (the `victory-shader` delta is 34 files, ~16.5k lines), so the run above is the branch as-is on its old base; it needs a rebase before a clean cherry-pick.
This discussion has been locked. Commenting is limited to contributors.
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#1049
No description provided.