Guard Spans::next_start, Spans::overlapping, page_written, and remapped against small/empty ranges #452

Closed
github-bot wants to merge 660 commits from github-bot/gh-452 into main AGit
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-29 18:15 UTC · original
ahmetbagci8:fix/gpu-spans-small-and-empty-ranges → main · +60036 −5427 · 206 files · 660 commits · closed without merging

Problem

In crates/victory-gpu/src/descriptor/host.rs:

  1. Spans::next_start(start, end) calls self.by_start.range(start.saturating_add(HEAD)..end). For any span shorter than HEAD (4096 bytes, e.g. small textures queried by Staging::judgement), start + HEAD > end, causing BTreeMap::range to panic (
    ange start is greater than range end).
  2. Spans::overlapping(start, end) lacks an end <= start guard: end < start panics in BTreeMap::range, and start == end still matches any span strictly containing start.
  3. page_written(at, len) and
    emapped(at, len) do not return early when len == 0, enqueueing (at, at) which slots_in / overlapping then treats as touching any texture containing t.

Fix

  • Return None in Spans::next_start when start.saturating_add(HEAD) >= end.
  • Return Vec::new() in Spans::overlapping when end <= start.
  • Return early on len == 0 in page_written and
    emapped.
  • Add unit test spans_next_start_and_overlapping_handle_small_empty_and_inverted_ranges.

Verification

  • cargo test -p victory-gpu --lib spans_next_start_and_overlapping (1 passed, 0 failed)
  • cargo clippy -p victory-gpu --tests (0 warnings)
**@⁠ahmetbagci8** on GitHub · 2026-11-29 18:15 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/452) `ahmetbagci8:fix/gpu-spans-small-and-empty-ranges` → `main` · +60036 −5427 · 206 files · 660 commits · closed without merging ## Problem In crates/victory-gpu/src/descriptor/host.rs: 1. Spans::next_start(start, end) calls self.by_start.range(start.saturating_add(HEAD)..end). For any span shorter than HEAD (4096 bytes, e.g. small textures queried by Staging::judgement), start + HEAD > end, causing BTreeMap::range to panic ( ange start is greater than range end). 2. Spans::overlapping(start, end) lacks an end <= start guard: end < start panics in BTreeMap::range, and start == end still matches any span strictly containing start. 3. page_written(at, len) and emapped(at, len) do not return early when len == 0, enqueueing (at, at) which slots_in / overlapping then treats as touching any texture containing t. ## Fix - Return None in Spans::next_start when start.saturating_add(HEAD) >= end. - Return Vec::new() in Spans::overlapping when end <= start. - Return early on len == 0 in page_written and emapped. - Add unit test spans_next_start_and_overlapping_handle_small_empty_and_inverted_ranges. ## Verification - cargo test -p victory-gpu --lib spans_next_start_and_overlapping (1 passed, 0 failed) - cargo clippy -p victory-gpu --tests (0 warnings)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 18:18:21 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-29 19:09 UTC · original

Thanks for the small and empty range guards. I checked the diff: the BTreeMap range is now constructed only when from < end, and empty writes/remaps return before touching the tracking state. Please retain a positive ordinary overlap/next-start case alongside the boundary regression.

**@⁠TaynanGT** on GitHub · 2026-11-29 19:09 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/452#issuecomment-7261051650) Thanks for the small and empty range guards. I checked the diff: the BTreeMap range is now constructed only when from < end, and empty writes/remaps return before touching the tracking state. Please retain a positive ordinary overlap/next-start case alongside the boundary regression.
github-bot closed this pull request 2026-11-30 17:08:31 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-30 17:05 UTC · original

main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

**@⁠TaynanGT** on GitHub · 2026-11-30 17:05 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/452#issuecomment-7285717065) `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.