D3D12.X: check vertex range overflow and SizeInBytes truncation in bind::draw_rects #1551
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T17:41:24Z.
bind::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.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T19:02:53Z.
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
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:32:32Z.
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!
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T23:25:15Z.
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.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:48:23Z.
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
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:33:02Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:07:26Z.
Triage (#1607) – head
618f4c2No open or merged PR makes the same change. #266 changes the same
draw_rectsbut picks the rect's corner vertex, not range checks.rect_vb_rangeis correct: checkedfirst_vertex * stride,va + offsetandrects * 6 * stride, withu32::try_fromforSizeInBytes. Theu64::MAX - 16test case does exercise the overflow path.Nit: the new function and its doc comment were inserted between
draw_rects' doc comment anddraw_rects, so the existing rect-list description now attaches torect_vb_rangeanddraw_rectsloses its doc.The branch conflicts with main and needs a rebase.
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.