Fix #2413: use saturating_add for view end bounds in aliases #3015
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3017"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by tharun-37 on 2026-11-26T03:29:41Z.
Fix #2413: use saturating_add for view end bounds in aliases
In xmem::aliases, end uses saturating_add but the view-range checks used unchecked addition (*base + size, base + size), which can overflow/panic. Use saturating_add consistently.
Additionally:
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T03:43:39Z.
Review: CHANGES_REQUESTED
Code review on
541938dc(static source inspection):emit/lower.rs(med3/nan_safe_min/nan_safe_max) changes bundled in this PR:crates/victory-shader/src/emit/lower.rs:2266-2295in addition toxmem.rs, which is unrelated to#2413(aliasesview end bounds) and appears to come from a separate branch/base. Please drop thelower.rshunk and rebase onto currentmain.aliasesstill panics on empty (len == 0) queries (crates/victory-hle/src/modules/xmem.rs:405-419):len == 0(e.g.,aliases(0x10000, 0, &mut out)),end == at, sophysical.views.range(at.saturating_add(1)..end)passes a reversed range (0x10001..0x10000) toBTreeMap::rangeand panics. Returning early whenend <= at(and adding a unit test for both empty and overflowing queries) completes the bounds fix.Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T03:47:44Z.
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
541938d(on its base940d32f).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 696 passed, 0 failed, 10 ignored.#[test]functions in the diff.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T04:37:42Z.
Review: APPROVED
LGTM on the fix itself (end<=at early-out, saturating_add on both bound comparisons, boundary tests all discriminate). Heads-up: #3037 contains this identical xmem/aliases change plus its write-watch fix — whichever merges second gets a conflict; may be worth rebasing one onto the other.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:15:34Z.
Automated triage for the maintainers.
Thanks for the reply and for updating the description. The head is unchanged, and you agree the guards in
xmem.rs::aliasesfix no reachable case, so the proposed close stands. The PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the labeltriage: proposed close.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by tharun-37 on 2026-11-26T06:18:01Z.
Removed the decompiled-code attribution from the description per the asset policy.
On the first point: you're right that liases has no real caller on main except its own test, so these guards fix no live bug today. The saturating_add change is still correct defensive hygiene (the original code could panic on usize::MAX inputs), but I agree the early-return and tests are mostly defensive. If you'd prefer to close this and land just the core saturating_add one-liner as #90 already does in larger PRs (#1017, #39, #523, #1241), I'm fine with that — closing #3017.
Imported from Marvisak/VIctory. Originally posted by tharun-37 on 2026-11-26T09:57:57Z.
Closing to focus on new issues
Pull request closed