Repository navigation
Conversation
…cl-dev#1130) is_adopted() previously dereferenced *(obj as *const usize) without checking pointer alignment. When this_first(a, b) inspects both arguments of a struct-returning device hook such as GetCustomHeapProperties (whose return buffer D3D12_HEAP_PROPERTIES is [u32; 5], 4-byte aligned), a 4-byte-aligned stack buffer triggers UB and aborts debug builds with a misaligned pointer dereference panic. Require pointer alignment in is_adopted() before readable() and the vtable read (adopted COM objects are always pointer-aligned), cache the this_first() result once in get_resource_allocation_info2_x(), and add unit and host-driver ABI parity tests for 4-byte-aligned return buffers in both C++ and C calling conventions. Fixes xcl-dev#1130 Assisted-by: Antigravity (Gemini 4 Neon)
Owner
Author
|
Upstream PR xcl-dev#1139 was closed or merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes xcl-dev#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=4: 743 passed, 0 failed, 41 ignored.SKIPPEDGPU tests on this adapter (Wave32-only):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64cargo test -p xcl --lib this_first_tests -- --nocapture: 2 passed, 0 failed.cargo test -p xcl --lib custom_heap_properties_match_host_in_cpp_and_c_abi -- --nocapture: 1 passed, 0 failed.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, ran the workspace test suite and smoke regression, and drafted this PR description.Mirror of xcl-dev#1139 (auto-synced, do not edit).