D3D12.X: warn when a root argument write runs past its parameter #3512
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3512"
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 Pipodi on 2026-11-30T07:46:25Z.
Logs a root argument write that runs past its parameter. A retail title's BVH builder writes 4 dwords into compute parameter 3, the last of a 9-dword table (3 fit); before #1319 (merged) the write was dropped whole and nothing in the log said so (with #1319 alone, in our diagnostic tree, the count of 24-byte corrupted runs in the title's vertex and index lists went from 80 to 0; test report on #1319; part of #2867). Two investigations each added the same line locally.
What is in it
D3D12.X: warn when a root argument write runs past its parameter(crates/xcl/src/hle/d3d12x/bind.rs, +19 lines):put_inlogs one line per distinct shape (list kind, parameter, offset, dwords written, dwords that fit, table size in dwords), at most 8 shapes. No env switch, no change to what is written, no return-type change.AtomicBoolchecked before the lock).Tested
006d650e, on main9dfbe3ea(which has #1319).cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on006d650e: 2885 passed, 1 failed, 51 ignored, 25SKIPPED. The failure,gpu_direct_image_get_resinfo_d16, is main's (fixed on main by #3513) and fails on the previous head too.Regression run
The same retail title for 60 s on both sides,
scripts/smoke.ps1on clean trees, release builds,XCL_PREPARE=0andXCL_PRESS_AT=16:Aon both sides, RTX 4090 (driver 621.40).main (
6bfb5c51):This PR's head (
006d650e, no uncommitted changes):The PR's run got 100.0 % of
main's frames and 99.4 % of its peak commit.Not tested
AI use
006d650e: Claude Code, Claude Opus 5.5 (main session) orchestrated it and updated this description; a Claude Sonnet 5.5 subagent made the change; subagents ran the suite and the smoke pair.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:49:35Z.
merge-check
base:
7d86c5d2b7head:
a73545492dmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (bind.rs, +16). Diagnostics only: one extra comparison per root write, and a warning for the first 8 shapes of a root-argument write that runs past its parameter. Findings: (1)
SEEN.lock()(~1484) is taken on every overrun even after 8 shapes are logged, so a title that overruns on every dispatch takes a global mutex from every thread recording command lists; an atomic "full" flag checked first would avoid that. (2) A write to a parameter index the layout doesn't have still returns silently. The PR's CI failure is the intermittent access violation in the lib test binary duringgpu::agility::tests(inside D3DSCache.dll) that this diff doesn't reach; see the run above. Fine: the bounds are right (constants up toat + count*4, descriptor 8 bytes, table 4), and the write itself is unchanged. No smoke run: a diagnostics change.performance: no smoke run (the default path doesn't reach this change); not measured. Diagnostics only: one comparison per root write on the default path.
verdict: safe to merge (finding 1 is worth a follow-up if a title overruns on every dispatch)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:06:49Z.
Triage (#1607) – head
a735454No open or merged PR adds this warning; #3511 (same author) only adds tests of the same
put_inclamping and does not overlap.bind.rs:put_in: the check costs one compare per write and the lock is only taken on an overrun, capped at 8 distinct shapes. 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.
Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-01T19:18:10Z.
Thanks. Finding 1 is right:
SEEN.lock()was taken on every overrun, because theseen.len() < 8test came after the lock, so after 8 shapes a title that overruns on every dispatch still took the mutex from each recording thread (the triage note that the lock is capped at 8 only counted the pushes, not the lock).Added an
AtomicBoolFULLinput_in, set when the 8th shape is stored and checked before the lock, so after the cap an overrun costs one relaxed load. The warning output and the write are unchanged. No new test: the change is a lock-avoidance on a log path, and the existing behaviour (8 shapes at most) is unchanged.Claude Code (Claude Sonnet 5.5) assisted with the change and this reply.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T20:49:08Z.
Follow-up review (head
006d650e, sincea735454, diff read, not a merge-check):SEEN.lock()taken on every overrun after the cap: fixed.FULL(bind.rs~1481) is checked before the lock and set once 8 shapes are logged (~1489), so later overruns cost one relaxed load.bind.rs~1474, unchanged); it was a follow-up suggestion, not a blocker.New: none.
Fine: still diagnostics only; the bytes written and the clamp to
limitare unchanged; the shape key and dword counts are right for constants, descriptors and tables, including anoffsetpastcount.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T21:08:01Z.
merge-check
base:
f07e426dadhead:
006d650e87merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2904 passed, 0 failed, 51 ignored (base
6bfb5c5+ README-onlyf07e426d: 2904 passed); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: nonereview: read the whole diff (
bind.rs, +19; diagnostics only). No findings beyond Foniass's follow-up review, whose open note (a write to a parameter index the layout does not have still returns silently) stands.hle::d3d12x::bind::tests::out_of_bounds_root_constants_do_not_clobber_adjacent_parameterwith--nocapturelogs three shapes:compute parameter 0 offset 2 dwords: 1 dwords written, 0 fit; table 4 dwords... offset 1 dwords: 3 dwords written, 1 fit ...... offset 4294967295 dwords: 1 dwords written, 0 fit ...write_end = end.min(limit), as on main).FULLskips the lock. Nothing tests the cap itself (a log line; none required).performance: one compare per root argument write; the lock and the log only on an overrun, until 8 shapes are logged.
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T09:46:20Z.
merge-check
base:
1c8b551475head:
006d650e87merge: clean (trial-merge commit d1bdb7a0b325a52575e2d3446e60e8448fb92e3b, git diff --check clean)
build: cargo build --workspace ok; cargo build --release -p xcl ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture (43 targets): 2909 passed, 0 failed, 51 ignored (all 43 targets green on clean rerun after an unrelated pre-existing ASLR collision on synthetic pointer 0x7c000041 in main's set_pipeline_state_goes_into_a_run_only_with_a_two_pass_pipeline -> real.rs:1237 and pre-existing #3441 flake in gpu_two_pass_cache_e2e.rs:584 on the first pass). Verified hle::d3d12x::bind::tests::out_of_bounds_root_constants_do_not_clobber_adjacent_parameter passed and emitted all 3 expected overrun warning lines cleanly (including offset 4294967295 with 0 fit). 28 SKIPPED lines (host environment only: 22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)).
review: Read the full merged diff (+19/-0 in crates/xcl/src/hle/d3d12x/bind.rs::put_in). Adds a lock-free
AtomicBoolfast path (FULL) gating a poison-safeMutex<Vec<_>>that deduplicates up to 8 distinct(gfx, i, offset, written, fit, table)overrun shapes underend > limitand logs onexlog_warnper shape. Uses write_end.saturating_sub(at) / 4 so at >= limit reports 0 fit without underflow, leaves valid writes at one branch with no lock, and preserves all existing clamping semantics. No scope creep, UB, or lock-order issues.performance: 60 s retail smoke (title: 29640639): 1657 frames (+13.3% vs
1c8b5514baseline 1462 frames), 14607 MB peak commit (-9.0% vs 16043 MB baseline), 0 device removals, 0 crashes.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:12:21Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
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.