Skip to content

Shaders: reject overlapping DXBC container parts - #343

Open
pedrofort wants to merge 1 commit into
Marvisak:mainfrom
pedrofort:fix-dxbc-overlap
Open

pedrofort wants to merge 1 commit into
Marvisak:mainfrom
pedrofort:fix-dxbc-overlap

Conversation

@pedrofort

Copy link
Copy Markdown

Problem

Container::parse() validates individual DXBC part boundaries but does not check whether multiple parts overlap.

As a result, malformed containers with duplicate part offsets or nested parts are accepted.

Fix

  • Collect and sort the byte ranges of parsed parts.

  • Reject intersecting ranges with ShaderError::Malformed.

  • Preserve the original part order.

  • Allow valid adjacent parts, including empty payloads.

This complements #326, which addresses parts overlapping the container header rather than each other.

Verification

Apple M5, macOS arm64, Rust 1.98.1, base commit d2a4bae.

Test | Before | After -- | -- | -- Duplicate offsets | FAIL | PASS Nested part | FAIL | PASS Adjacent empty parts | PASS | PASS Complete shader unit test suite | — | 59/59 PASS

Clippy (--lib -- -D warnings): clean.

The existing non-Windows constant_color dead-code warning is unchanged.

All test containers are synthetic. No game data was used.

AI-assisted implementation and test preparation (ChatGPT), with tests executed locally on Apple Silicon.

muhammed-aksoy pushed a commit to muhammed-aksoy/VIctory that referenced this pull request Nov 24, 2026
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremygold02

Copy link
Copy Markdown
Contributor

Tested PR #343 at head 9459c12d2e3a3d48ac2e073e7d3d9a888bfa913d (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 9459c12d2e3a3d48ac2e073e7d3d9a888bfa913d.

  • cargo test --locked -p victory-shader overlap_ — passed (ok. 3 passed; 0 failed; 0 ignored; 0 measured; 69 filtered out; finished in 0.00s ); cases: dxbc::tests::overlap_rejects_duplicate_offsets, dxbc::tests::overlap_accepts_adjacent_empty_parts, dxbc::tests::overlap_rejects_nested_part.

Behavior covered: Checks duplicate and nested DXBC part offsets are rejected while adjacent empty parts remain accepted.
Code: crates/victory-shader/src/dxbc.rs

@ghost ghost mentioned this pull request Nov 24, 2026

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 9459c12 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (267 passed, 0 failed). victory translate <title exe> --validate --pipelines gives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. So the title's embedded containers still parse with the stricter check, which was the regression I wanted to rule out.

Sorting (offset, offset + 8 + len) and rejecting end > next start catches duplicate offsets and nested parts. Adjacent parts, including empty ones (end == next start), stay valid, and parts keeps its original order because only the copy is sorted.

No issues found. Nit: the PR description is pasted rich HTML, which renders oddly on GitHub. Plain Markdown would read better.

AI-assisted (Claude Code).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…ainer parts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sebastianspicker

Copy link
Copy Markdown

I think #326 covers this. I copied the three tests from this PR unchanged into #326 at bf594d5, and all three pass there. On main (ffe310e), overlap_rejects_duplicate_offsets and overlap_rejects_nested_part fail as expected, and overlap_accepts_adjacent_empty_parts passes. #326 also checks a part reaching into an earlier one and parts inside the header, so it's the wider version of the same fix.

If the maintainer prefers this one because it's smaller, the sort-then-windows(2) check looks right to me; adjacent and empty parts stay valid. Otherwise this could close once #326 merges.

AI-assisted.

Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
…isak#306 Marvisak#333 Marvisak#105 Marvisak#288 Marvisak#343 Marvisak#353 Marvisak#326 Marvisak#259 Marvisak#179 Marvisak#176 Marvisak#226 Marvisak#286)

Conflicts:
- emit/lower.rs: shader-opcodes and shader-tracking each keyed heap
  handles by the resource properties (a tuple vs two flattened words);
  the same key, shader-tracking's form and comment kept. Lowered's
  test-only fields, test imports and tests of both sides kept.
- emit/wave.rs: tests of both sides kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…#1504, verified together

Merges Marvisak#1145 Marvisak#343 Marvisak#1042 Marvisak#1303 Marvisak#477 on top of the stack of Marvisak#1504 (Marvisak#1319,
Marvisak#1402, Marvisak#1492, Marvisak#1504, on main ffe310e), each head unchanged, no conflicts
and no changes of mine. cargo clippy --workspace --all-targets --locked
-- -D warnings, with and without --all-features, is clean and cargo test
--workspace --locked passes (406 passed, 6 ignored; main has 342 passed,
6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…#1504, verified together

Merges Marvisak#1145 Marvisak#343 Marvisak#1042 Marvisak#1303 Marvisak#477 on top of the stack of Marvisak#1504 (Marvisak#1319,
Marvisak#1402, Marvisak#1492, Marvisak#1504, on main ffe310e), each head unchanged, no conflicts
and no changes of mine. cargo clippy --workspace --all-targets --locked
-- -D warnings, with and without --all-features, is clean and cargo test
--workspace --locked passes (406 passed, 6 ignored; main has 342 passed,
6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work. The overlap check in Container::parse (crates/victory-shader/src/dxbc.rs) is correct (sorted ranges, windows(2), touching and empty parts allowed); note the slice reads were already bounds-checked, so overlaps were never a memory-safety issue. Container::parse also reads the title's own shader containers, so a new rejection makes affected programs fail to translate, and this was tested only on synthetic containers. Please run translation over the title's shaders (e.g. victory translate --list) and report that no program that translated before is now refused; that would make it mergeable. #326 also contains an overlap check inside a large bundle; this smaller PR could be the one to take.

CI: no check runs on the head commit.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants