GPU: a pipeline stream's shader bytecode is read unaligned #2299

Merged
denkencar-sketch merged 1 commit from upstream-pr/2301 into main 2026-11-25 21:56:21 +00:00
denkencar-sketch commented 2026-11-25 10:05:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:05:40Z.


Summary

A pipeline stream is a byte slice that need not be 8-aligned; the reference made over it to read the shader bytecode was undefined behaviour and a panic in checked builds. It is now read unaligned.

Testing

Test a_stream_of_any_alignment_is_read aborts on main (misaligned dereference) and passes with this change. cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: a run in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601986658 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2301). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T10:05:40Z. --- ## Summary A pipeline stream is a byte slice that need not be 8-aligned; the reference made over it to read the shader bytecode was undefined behaviour and a panic in checked builds. It is now read unaligned. ## Testing Test `a_stream_of_any_alignment_is_read` aborts on `main` (misaligned dereference) and passes with this change. `cargo test --workspace --locked` passes apart from known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: a run in the game. AI-assisted.
catminou4 commented 2026-11-25 11:04:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:17Z.

Review: COMMENTED


Pipeline stream shader bytecode read unaligned (read_unaligned) — slice alignment not promised. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Correct fix for unaligned title buffers.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055713512 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2301#pullrequestreview-6055713512). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:17Z. **Review:** COMMENTED --- Pipeline stream shader bytecode read unaligned (read_unaligned) — slice alignment not promised. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Correct fix for unaligned title buffers.
Marvisak commented 2026-11-25 16:09:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:21:27Z.


Automated triage for the maintainers.

Merge candidate (worth a look). read_stream in crates/victory-gpu/src/pipeline.rs turned stream[at + 8..] into a &Bytecode reference. The stream is only a &[u8], and on the pre-build path (Prebuild::graphics, called from apps/victory/src/prebuild.rs) it comes from a Vec<u8>, so nothing guarantees 8-byte alignment: the reference is undefined behaviour and debug builds trap on it. The PR reads the Bytecode with read_unaligned, as GraphicsState::read in pipeline/host.rs already does for every other subobject. I checked the new test against subobject(): kind 1 is the 24-byte vertex subobject, and the loop stops cleanly at the end of the 32-byte slice. CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166714435 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2301#issuecomment-7166714435). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:21:27Z. --- <!-- victory-triage v1 head=aa4c609f67f377833025e9cf3d5a55135fbae5e0 verdict=merge-candidate at=2026-11-25T15:29:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** `read_stream` in `crates/victory-gpu/src/pipeline.rs` turned `stream[at + 8..]` into a `&Bytecode` reference. The stream is only a `&[u8]`, and on the pre-build path (`Prebuild::graphics`, called from `apps/victory/src/prebuild.rs`) it comes from a `Vec<u8>`, so nothing guarantees 8-byte alignment: the reference is undefined behaviour and debug builds trap on it. The PR reads the `Bytecode` with `read_unaligned`, as `GraphicsState::read` in `pipeline/host.rs` already does for every other subobject. I checked the new test against `subobject()`: kind 1 is the 24-byte vertex subobject, and the loop stops cleanly at the end of the 32-byte slice. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:03:37 +00:00
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2299
No description provided.