D3D12.X: check vertex range overflow and SizeInBytes truncation in bind::draw_rects #1561
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1561
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1561"
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?
@b3IKK on GitHub · 2026-11-24 17:41 UTC · original
b3IKK:d3d12x/bind-draw-rects-overflow→main· +41 −5 · 1 files · 1 commits · openbind::draw_rectscomputedva as usize + first_vertex as usize * stride as usize,first_vertex as usize * s + len, and(rects * 6 * s) as u32with unchecked arithmetic. Large title-suppliedfirst_vertexorstridevalues could panic in debug builds, wrap past the> bytesbounds check in release builds, or silently truncate the expandedD3D12_VERTEX_BUFFER_VIEW::SizeInBytes.This extracts
rect_vb_range()usingchecked_mul,checked_add, andu32::try_from, returningfalsefromdraw_rectswhen any range or size check fails.What is in it
crates/xcl/src/hle/d3d12x/bind.rs: addrect_vb_range(), use it indraw_rects, and add unit testrect_vb_range_rejects_overflow_and_u32_truncation.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): 976 passed, 0 failed, 45 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 -- rect_vb_range execute_indirect: 4 passed, 0 failed (the new test and the threeexecute_indirecttests next to it, one of which the rebase had to be merged around)Regression run
main (
20cf130, clean tree, no local changes):PR (
618f4c2, clean tree, no local changes):(The head is on
689f2db;mainmoved to20cf130while the suite ran, and the main block is that commit, run right after the PR's. Both peak higher than the blocks this PR had before, 14.6 GB: several long runs of the title on this machine in between filled its caches, and its runs now commit 17–20 GB in the first minute whatever the build. I have not isolated why.)Not tested
first_vertexorstride(the unit test callsrect_vb_rangedirectly)AI use
bind.rs, wrote the fix and unit test, rebased onto689f2db(resolving the conflict with the testmainadded at the same place), ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@futurepro62 on GitHub · 2026-11-24 19:02 UTC · original
Full-suite run, since this PR has no test report yet. Tested exact head
1d751bb(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 776 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.rect_vb_range_rejects_overflow_and_u32_truncation.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.hle::kernelx::tests::fine_timer_makes_short_sleeps_shortfailed (aSleep(1)timing check, sensitive to load). The run above was alone on the machine and is clean.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 19:32 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@b3IKK on GitHub · 2026-11-24 23:25 UTC · original
Rebased onto
689f2db(GitHub showed a conflict:mainhad added a test at the same place inbind.rs; both are kept, nothing else changed). Head618f4c2: 976 passed, 0 failed, 45 ignored; smoke blocks in the description. AI use: OpenCode, Claude Fable 5.2.@DavidM1911 on GitHub · 2026-11-26 05:48 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
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.