D3D12.X: check pointer alignment in is_adopted before dereferencing (#1130) #1139
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!1139
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1139"
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?
@GamingChelsea on GitHub · 2026-11-24 12:24 UTC · original
GamingChelsea:fix/is-adopted-alignment→main· +80 −3 · 2 files · 1 commits · openFixes #1130.
d3d12x::real::is_adoptedpreviously dereferenced*(obj as *const usize)without checking pointer alignment. Becausethis_first(a, b)probes both arguments of struct-returning device hooks — includingGetCustomHeapProperties(slot 26, returning[u32; 5], 4-byte aligned) — passing a 4-byte-aligned return buffer caused undefined behavior and aborted debug builds with a misaligned pointer dereference panic.What is in it
crates/xcl/src/hle/d3d12x/real.rs: require pointer alignment ((obj as usize) & (std::mem::align_of::<usize>() - 1) == 0) inis_adoptedbeforereadable()and the vtable read (adopted COM objects are always pointer-aligned); add unit testthis_first_tests::misaligned_return_buffer_is_not_adopted_and_does_not_paniccovering 4-byte-aligned stack buffers (including one containing a stale vtable copy).crates/xcl/src/hle/d3d12x/device_x.rs: cachereal::this_first(a, b)once inget_resource_allocation_info2_x; add GPU host-driver parity testcustom_heap_properties_match_host_in_cpp_and_c_abiverifyingget_custom_heap_properties_xin both C++(this, ret, ...)and C(ret, this, ...)ABI orders with a 4-byte-aligned[u32; 5]return buffer.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), debug (tests) and release (smoke).cargo test --workspace -- --test-threads=1: 1267 passed, 0 failed, 46 ignored.SKIPPEDGPU tests on this adapter: 25 (22 wave64-onlyno wave64skips + 3#1426f16/f32 direct-DXIL per-lane skips).Regression run
main:
PR head:
Not tested
stable-x86_64-pc-windows-gnullvmtoolchain (tested onstable-x86_64-pc-windows-msvc).AI use
this_firstcaching, wrote the unit and host-driver ABI parity tests, rebased onto06c9f55, ran the workspace test suite and smoke regression, and updated this PR description.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@DavidM1911 on GitHub · 2026-11-24 12:56 UTC · original
Independent verification on current
main384f7f7(branch already contains it — clean).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
cargo test -p xcl --lib adopt: 1 passed, 0 failed —misaligned_return_buffer_is_not_adopted_and_does_not_paniccovers the #1130 alignment check on the real backend path.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@Cecerw on GitHub · 2026-11-24 13:45 UTC · original
Tested on NVIDIA: passes
20a893f(onmain47efa2e)20a893f(onmain47efa2e), no local changes:.\scripts\test.ps1(cargo test --workspace -- --test-threads=4): 743 passed, 0 failed, 41 ignoredcustom_heap_properties_match_host_in_cpp_and_c_abiandmisaligned_return_buffer_is_not_adopted_and_does_not_panic: okNote: #1132 adds an integration test with the same name,
custom_heap_properties_match_host_in_cpp_and_c_abi(incrates/xcl/tests/d3d12_allocation_and_heap_info.rs), covering the same C++ / C argument orders. Whichever lands second may want to drop or rename its copy.Not tested: AMD, any title (no smoke run).
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@bjarngard on GitHub · 2026-11-24 13:48 UTC · original
Test report for head
20a893f(AMD)Tested
XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 743 passed, 0 failed, 41 ignored, no SKIPPEDmisaligned_return_buffer_is_not_adopted_and_does_not_panic,custom_heap_properties_match_host_in_cpp_and_c_abipassed when run alone on the AMD adapterNot tested: retail titles (no smoke run), RDNA3/RDNA4.
AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.
@JoaoPauluu on GitHub · 2026-11-24 14:21 UTC · original
A regression run under Wine on Linux, on a retail title.
Tested
x86_64-pc-windows-gnu.20a893fas it is (merge base47efa2e) andmain47efa2e, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Twelve runs in a row,mainfirst and last, other PRs in between.Regression run
main (first run):
this PR:
The last
mainrun: 1425 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@throny on GitHub · 2026-11-25 00:51 UTC · original
Two contributors checked independently and found that #1522 solves the same problem (for #1130) in a different way: #1607, group D67. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@DavidM1911 on GitHub · 2026-11-26 03:41 UTC · original
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.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.