D3D12.X: clamp root argument writes to the target parameter's size #1309
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1319"
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-24T14:40:45Z.
bind::put_inandconsole_list::closedestructuredParam::Constantswithout checkingcount, only bounds-checking against the entire root argument buffer. Writing constants withoffset + n > count(or writing past a 4-byte table / 8-byte descriptor slot) silently overwrote the adjacent root parameter, and large offsets could overflow inbind::put_in.This clamps writes to each parameter's own byte span using checked arithmetic in
bind::put_inand stops atoff + k >= countinconsole_list::close(while still advancingat += 1 + npast the recorded command packet).What is in it
crates/xcl/src/hle/d3d12x/bind.rs: clamp writes input_into the target parameter's byte span with checked arithmetic; add unit testout_of_bounds_root_constants_do_not_clobber_adjacent_parameter(verified failing before the fix).crates/xcl/src/hle/d3d12x/console_list.rs: stop constant writes atoff + k >= countinclose.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): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib out_of_bounds_root_constants_do_not_clobber_adjacent_parameter: 1 passed, 0 failed (failed before the fix, overwriting adjacent descriptor bytes)Regression run
main:
PR:
Not tested
AI use
bind.rsandconsole_list.rs, wrote the fix and unit test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:45:13Z.
Full-suite run, since this PR has no test report yet. Tested exact head
82b7cb3(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.out_of_bounds_root_constants_do_not_clobber_adjacent_parameter.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:24:13Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib -- --test-threads=1: 708 passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T11:40:52Z.
Test report for head
82b7cb3as pushed (not merged onto currentmain) – NVIDIA, wave32.Tested
.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignoredout_of_bounds_root_constants_do_not_clobber_adjacent_parameterran and passedXCL_SAMPLE_*data set (game-data tests not run)Not tested
mainAI use
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T13:19:14Z.
AMD RDNA3 (native wave64) test report for exact head
82b7cb3eb85843afd79c3961014e21dd70a7c6e5, as pushed on its base930e8b4(not merged onto currentmain).Tested
cargo build --workspace: okout_of_bounds_root_constants_do_not_clobber_adjacent_parameter: 1 passed;bindfilter: 11 passed, 0 failed, 0 ignoredcargo test --workspace --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored (summed over all test binaries)Not tested
scripts/smoke.ps1regression run (synthetic GPU/unit tests only)main; other GPUs (NVIDIA / Intel / RDNA2 / RDNA4)AI use: Claude Code (Claude Sonnet 5.5) ran the build and tests and wrote this report; the numbers are from the runs above.
Imported from ivall/xcl. Originally posted by vasanex on 2026-11-28T20:19:45Z.
Test report for
82b7cb3e, with a real case this PR fixes: the builder crash of #2867.The case.
XboxBvhBuilder.dllsets four root constants (SetComputeRoot32BitConstants, offset 0) on a pass whose root signature declares three (its hierarchy pass, recordc4d9c4a0c4839d0a).bind::put_instores a write only when all of it fits the root arguments, so the pass got none of the four: it ran with a null result-header pointer, read a primitive count of 0 and wrote nothing, and the next pass (ConstructBVH4) then built nodes from stale tables and stored them at node pointer 0 and far outside its result, into the title's own data. That is the "title reads bad addresses" crash of #2867. The console list path (console_list::close) already kept the constants that fit, which is why the builder's e2e tests pass. With this PR the three declared constants are stored and the fourth is dropped, which is what the pass needs.Tested
82b7cb3echerry-picked ontonvidia-devd1be8103(applies cleanly), plus one unit test of the builder's shape (more constants than the parameter declares, at offset 0 and at an offset inside it, compute and graphics):cargo test -p xcl --lib -- root_constants --test-threads=4: 2 passed, 0 failed, 0 ignored (this PR'sout_of_bounds_root_constants_do_not_clobber_adjacent_parameterand the added one). Ond1be8103without the PR the added test fails (0 passed, 1 failed: the arguments stay[0, 0, 0, 0]where[1, 2, 3, 4]is expected).main765b2c5bstill has the sameput_in.nvidia-dev54225f58with the open PRs our runs need merged (#2905 #2987 #3039 #2815 #2816 #2817 #3037 #609 #2753 #2975 #3052 #2590 #3091 #3092 #2229, and #3094 off) and local changes; this PR's two hunks applied by hand (a local fix of the same lines was in the way of a clean cherry-pick), with a local switch that putsnvidia-dev'sput_inback for the comparison:put_in, three runs: a local log line shows the case in each ("compute root constants of parameter 3 at byte 24 of 36 past the signature: 12 of 16 bytes kept": the arguments are 36 bytes, the parameter's three constants are their last 12, the title sets four). Two runs reached the world (at 513 s and 537 s) and went on to the end of the 760 s with no crash and no device removal. The third reached it at 449 s and crashed at 689 s on something else: the title read a page XCL had moved to its other mapping 207 ms before (the limit of #1031), not the builder.nvidia-dev'sput_in, one run: the same writes are dropped whole ("16 bytes of parameter 3 at byte 24 of 36 dropped whole"), the world is reached at 483 s, and 31 s later the title crashes reading address0xffffffffffffffff(unhandled exception 0xc0000005in the title's code), the bad-address crash of #2867.Not tested
930e8b4), andmain: the title does not get as far as the builder onmainon this machine.console_list::closehunk: the title's builder goes throughbind::put_in.AI use
Imported from ivall/xcl. Originally posted by Parakeet-Wheat on 2026-11-30T03:13:08Z.
merge-check
base:
45ebed1005head:
82b7cb3eb8merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2827 passed, 0 failed, 51 ignored; SKIPPED: 29 (22 no wave64, 3 wave32 per-lane form refused (#1426), 2 no heap windows, 1 driver cache needs Developer Mode, 1 no GPU_UPLOAD heaps); failing: none
review: No blocking finding; whole diff read. With both non-test hunks reverted,
out_of_bounds_root_constants_do_not_clobber_adjacent_parameterfails; with them restored, it passes. The test covers onlybind::put_in. No test exercises theconsole_list::closechange. The clamp sizes match the layout: constants take 4 × count bytes, a descriptor 8 and a table 4 (console_list.rs:149-151). Every table and descriptor caller inbind.rswrites exactly 4 or 8 bytes, so only constant writes change. A constant write that runs pastcountnow keeps the part that fits and drops the rest.performance: Boot-only smoke pair, 60 s, no input, release,
XCL_NETWORK=0: base 1534 frames, peak commit 19882 MB; merge 1614 frames, peak commit 15318 MB. Both runs show 0 device removals and 0 crashes. The base run's last presents per 2 s are 61 53 49, and its peak commit is 4.5 GB higher; we did not rerun it to find why. Default path: each root argument write input_inadds up to five checked operations and onemin.verdict: safe to merge (the new test fails without the fix, and the suite and smoke pair show no regression on our RTX 3070)
hardware / tool and model: RTX 3070 8 GB (610.88), AMD Ryzen 5 5600X, Windows 11 Home 26300, Rust 1.95.0, debug (smoke in release) / Claude Code, Claude Opus 5.5 (merge, build, suite, mutation, smoke and review)
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T03:19:25Z.
merge-check claim
head:
82b7cb3eb8Imported from ivall/xcl. Originally posted by relativespace2K on 2026-11-30T03:20:19Z.
merge-check
base:
53e85fb1head:
82b7cb3eb8merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2789 passed, 6 failed, 49 ignored; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in
--test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base53e85fb1alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR; its new test passed. 13 SKIPPED lines, all environmental: no D3D12 debug layer / d3d12SDKLayers.dll, no heap windows, no GPU_UPLOAD, per-lane f16/f32 forms refused.review: no blocking finding; two files, every hunk read.
put_innow carries each parameter's own end (Constantsfrom its count, aDescriptor8 bytes, aTable4) and clamps the write to it, so a root constant past the parameter can no longer land in the next parameter's bytes; the arithmetic ischecked_addthroughout, which is why an offset ofu32::MAXis dropped instead of panicking, and the console list's constant loop stops at the same count. The test pins exactly the reported failure (offset 2 of acount=2parameter must leave the CBV beside it untouched), the partial-write case (3 dwords from offset 1 keep only the one that fits) and the overflow case. One note, not blocking: too-long writes are clamped and the fitting prefix is copied rather than the call being refused, which is the safe direction but means a title with a wrong root signature keeps running with truncated data instead of failing loudly; D3D itself would flag that use only under the debug layer. No duplicate: nothing else bounds root arguments; #1435 and #2504 are the root-argument signature fixes.performance: two comparisons per root argument write, at command recording time; nothing per draw.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T03:25:35Z.
merge-check
base:
a7980178a8head:
82b7cb3eb8merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2833 passed, 1 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check: diff read for safety (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T07:36:56Z.
Test report for
82b7cb3eon a retail title. It looks at the same builder pass as vasanex's report above, and at a second symptom of the #2867 cause.What we tested
SetComputeRoot32BitConstantsat offset 0 on the last parameter of their table: 4 dwords into a 3-constant parameter (parameter 3, 9-dword table), and 6 dwords into a 5-constant parameter (parameter 6, six root UAVs followed by constants(5), 17-dword table). No write past a parameter in the middle of a table was seen.main,put_indrops both writes whole (53e85fb1bind.rs:1471, 72 > 68 bytes for the second shape).c4d9c4a0c4839d0a. With it null, the pass reads a node count of 0 and stores no parents, and the next pass (290043819c198954) then loads parents that were never written.Effect, in our diagnostic tree (main
af2cecc4+ local diagnostics + #1319's bind.rs change, identical lines), run r262 against run r261 without the change:290043819c198954: 30.7M → 1. The header pointer at cb+0x18 is now non-null in 11 of 11 logged builds. The radix pass stores in 96 % of its dispatches.ea1258f8(#2504, now onmain). The fix is credited to this PR because the clipped write is logged ("parameter 3 offset 0 dwords: 4 dwords written, 3 fit") and the header pointer it carries is now set.Main-based runs
53e85fb1+ #3214 + local press commits. M1 is M0 + this PR + a one-line warning. Both built cleanly. In runs of 420 s and 720 s, in release, every measured run of both arms exited 0x0, with 0 device removals and 14 of 14 presses.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 2799 passed, 1 failed, 49 ignored, 28 SKIPPED. The failure ishle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, which ismain's own test and was since fixed by #3474.Tested
Not tested
main. In 420 s and 720 s, neither M0 nor M1 got past the cinematic and menus into the open-world scenes where the fans appeared. Both arms show coherent characters in the cinematic and look the same frame for frame, so the fans were not judged with this PR on any tree: the result is the corruption count above.930e8b4.console_list::closehunk: the title's builder goes throughbind::put_in.AI use