draw.rs rectangle-list fallback: u32 first + count wraps before the bounds check; SizeInBytes can truncate #223

Open
opened 2026-11-26 12:04:47 +00:00 by github-bot · 0 comments
Owner

@⁠kekonn on GitHub · 2026-11-26 11:59 UTC · original

crates/victory-gpu/src/draw.rs:3805: || u64::from(first + count) * stride > u64::from(v.size) adds the two values in u32 before widening. Release builds (and diag, which inherits them) don't check for overflow, so the sum wraps and the bounds check can pass. Further down, SizeInBytes: (rects * 6 * stride) as u32 (~3836) can truncate.

The damage is limited: shadow::find(from, rects*3*stride) (3806) still requires a registered title buffer covering the whole range. This is hardening, not a crash anyone has seen.

When: only the CPU fallback for RECTANGLES pipelines that did not get the rectangle geometry stage. It also needs a direct draw with first + count >= 2^32, or a range of 4 GiB or more.

Proposed fix (~4 lines)

Compute (u64::from(first) + u64::from(count)) * stride, and build SizeInBytes with u32::try_from(…), returning false on overflow.

Upstream: no open PR changes rectangles(). #53 adds a diagnostics hunk just above it.
Status: a fix is being prepared in kekonn/VIctory-7900XTX on branch claude/gifted-clarke-uxuqw8.


Generated by Claude Code

**@⁠kekonn** on GitHub · 2026-11-26 11:59 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/223) `crates/victory-gpu/src/draw.rs:3805`: `|| u64::from(first + count) * stride > u64::from(v.size)` adds the two values in `u32` before widening. Release builds (and `diag`, which inherits them) don't check for overflow, so the sum wraps and the bounds check can pass. Further down, `SizeInBytes: (rects * 6 * stride) as u32` (~3836) can truncate. The damage is limited: `shadow::find(from, rects*3*stride)` (3806) still requires a registered title buffer covering the whole range. This is hardening, not a crash anyone has seen. **When:** only the CPU fallback for RECTANGLES pipelines that did not get the rectangle geometry stage. It also needs a direct draw with `first + count >= 2^32`, or a range of 4 GiB or more. ### Proposed fix (~4 lines) Compute `(u64::from(first) + u64::from(count)) * stride`, and build `SizeInBytes` with `u32::try_from(…)`, returning `false` on overflow. **Upstream:** no open PR changes `rectangles()`. #53 adds a diagnostics hunk just above it. **Status:** a fix is being prepared in kekonn/VIctory-7900XTX on branch `claude/gifted-clarke-uxuqw8`. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:04:47 +00:00
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/avatarmanz--VIctory-7900XTX#223
No description provided.