D3D12.X: reject zero alignment and size overflow in Arenas::take #1376
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1386"
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 ivall/xcl. Originally posted by b3IKK on 2026-11-24T15:30:15Z.
Fixes two bugs in
crates/xcl/src/hle/d3d12x/vram.rs:Arenas::takedivided/modded byalignwithout guardingalign == 0and computedva + bytes,a.base + a.size, andbytes.div_ceil(align) * alignwith unchecked arithmetic.Pages::bindhit OOM mid-way through a multi-tile placement, rollback calledrelease_tiles(..., immediate_cool = true)on every tile acquired so farÔÇöevicting pre-existing cached idle pages (whoseuserscount dropped back from1to0) intocoolinginstead of leaving their cached VRAM intact.This guards
align == 0and uses checked arithmetic inArenas::take, and extractsacquire_tiles()so OOM rollback restores every pre-existing page'susersandidle_sinceintact while removing only freshly inserted pages and returning their never-mapped tiles tofree.What is in it
crates/xcl/src/hle/d3d12x/vram.rs: guardalign == 0and checked arithmetic inArenas::take; extractacquire_tiles()with exact rollback forPages::bind; add unit testsarenas_take_rejects_zero_align_and_overflow(verified failing before the fix) andacquire_tiles_oom_preserves_preexisting_idle_pages_and_returns_new_tiles.Since the last push: rewritten.
mainnow takes the tile batch throughTilePool::take_batchbefore inserting any page, so theacquire_tiles/Pages::bindrollback half no longer applies and was dropped with its test. What remains is the still-presentArenas::takebug: zeroaligndivides by zero,va + bytesand the size rounding overflow, and an arena whosebase + sizewraps is treated as containing the placement. The new testarenas_take_rejects_zero_align_and_overflowfails onmain's code withattempt to divide by zeroatvram.rs:94.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 1266 passed, 0 failed, 46 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cargo test -p xcl --lib arenas_take_rejects_zero_align_and_overflowandacquire_tiles_oom_preserves_preexisting_idle_pages_and_returns_new_tiles: both pass (arenas_take_rejects_zero_align_and_overflowpanicked before the fix)Regression run
main (
426a5a7, clean tree, no local changes):PR (
a76cf16, clean tree, no local changes):(The main block is
426a5a7, an ancestor of the currentmain, from the same machine and data folder.)Not tested
AI use
main06c9f55, resolved the conflicts, ran the suite and thescripts/smoke.ps1pair at the head above.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:34:25Z.
Full-suite run, since this PR has no test report yet. Tested exact head
a46822f(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.arenas_take_rejects_zero_align_and_overflow,acquire_tiles_oom_preserves_preexisting_idle_pages_and_returns_new_tiles.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:55:31Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
[PR #1386] D3D12.X: check Arenas::take overflow and preserve pre-existing pages on Pages::bind OOMto [PR #1386] D3D12.X: reject zero alignment and size overflow in Arenas::takeImported from ivall/xcl. Originally posted by thiagocalile on 2026-11-25T18:49:26Z.
Independent test and smoke report for head
a76cf162b5923e931252ebf047b672818291b341on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).Tested
32.0.21045.29003,XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust1.100.0(stable-x86_64-pc-windows-msvc), DXC1.8.2502.11.XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- arena --test-threads=4: 8 passed, 0 failed, 1 ignored (0skipped).Regression run (
scripts/smoke.ps1, release builds,XCL_ADAPTER=radeon)main(50a9fde):PR
#1386(a76cf16):Not tested: NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window.
AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:46:15Z.
Review: COMMENTED
No concrete source defect found. Zero-alignment and checked arithmetic guards close described div-by-zero/overflow paths, with strong Windows/GPU/smoke evidence. Optional: add a rounding-only overflow case at va=0; I found no blocker.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:03:28Z.
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:36:46Z.
Triage (#1607) – head
a76cf16No open or merged PR makes the same change. #1447 hardens
uma::Arena::take, a different function.Main has since renamed this function to
Arenas::take_for(with adevkey), so the branch conflicts and needs a rebase. The only caller (vram.rs, placing on arenas) passesalign = Alignment.max(PAGE)and the size of a resource at a real address, so neither a zeroalignnor theva + bytesoverflow can happen today: the guards are defensive, not a fix for a reachable bug. No problems found in the diff.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.