D3D12.X: read the adopted vtable pointer unaligned in is_adopted #1424

Closed
JorgeMJM wants to merge 1 commit from upstream-pr/1434 into main
JorgeMJM commented 2026-11-24 15:54:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JorgeMJM on 2026-11-24T15:54:39Z.


Fixes #1130.

this_first passes both arguments of struct-returning hooks to is_adopted, including 4-byte-aligned return buffers such as D3D12_HEAP_PROPERTIES. The aligned 8-byte load is UB and aborts debug builds with a misaligned-pointer panic. read_unaligned() answers the same question with no trap; genuine adopted objects are heap COM pointers and never misaligned, so no verdict changes.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: is_adopted uses (obj as *const usize).read_unaligned(); new regression test four_byte_aligned_return_buffer_does_not_trap in this_first_tests.

Tested

  • Hardware: RTX 3070 Laptop 8 GB (OEM OC profile via Lenovo Vantage, core 2.10 GHz; VRAM stock 7001 MHz; sustained clock not sampled), driver 621.40, Windows 11 26300, rustc 1.100.0, debug + release.
  • cargo test --workspace -- --test-threads=4: lib 708 passed, 0 failed, 21 ignored (2 GPU tests SKIPPED on this adapter); all other targets green, 0 failed. One full-suite run hit coherent_buffer_sanitizes_console_flags_and_state failing at VirtualFree; it passes in isolation and in the rerun and on clean origin/main (707/707) — flake, left untouched as a separate issue.
  • New test fails without the fix (exact abort from the issue: misaligned-pointer panic, exit 0xc0000409) and passes with it. The without-fix run was measured pre-rebase (base 508a0c7 + fix, test against reverted line); the with-fix result holds on this PR's head.
  • Review: advisor agent found nothing blocking (keep); its one nit (readable precondition) is in.

Regression run

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 3070 Laptop GPU
title: 78b7bda4
seconds: 60
exit: 0x0
frames shown: 1532 (PresentX 1532)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15259 MB
xcl-smoke v1
commit: a4202ed12b80d5bda0069d1e36fd0aa7df996008
gpu: NVIDIA GeForce RTX 3070 Laptop GPU
title: 78b7bda4
seconds: 60
exit: 0x0
frames shown: 1467 (PresentX 1467)
presents per 2 s (last 3): 60 60 58
device removals: 0
crashes: 0
peak commit: 14784 MB

Not tested

  • AMD GPUs; other titles.
  • Not confirmed whether the smoked title hits the misaligned-buffer path (no GetCustomHeapProperties trace in the smoke logs); the run counts as a no-regression check on the touched area.
  • The flake above was not investigated further.

AI use

  • opencode-go (muse-spark-1.3): wrote the fix, the regression test, ran the suites/smokes and this description.
  • Advisor review by a second agent (Opus 5.5, per operator): keep, no blocking findings.
<!-- greyfinch-sync:ivall/xcl:issue:6585861233 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1434). Originally posted by [JorgeMJM](https://github.com/JorgeMJM) on 2026-11-24T15:54:39Z. --- Fixes #1130. `this_first` passes both arguments of struct-returning hooks to `is_adopted`, including 4-byte-aligned return buffers such as `D3D12_HEAP_PROPERTIES`. The aligned 8-byte load is UB and aborts debug builds with a misaligned-pointer panic. `read_unaligned()` answers the same question with no trap; genuine adopted objects are heap COM pointers and never misaligned, so no verdict changes. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: `is_adopted` uses `(obj as *const usize).read_unaligned()`; new regression test `four_byte_aligned_return_buffer_does_not_trap` in `this_first_tests`. **Tested** - Hardware: RTX 3070 Laptop 8 GB (OEM OC profile via Lenovo Vantage, core 2.10 GHz; VRAM stock 7001 MHz; sustained clock not sampled), driver 621.40, Windows 11 26300, rustc 1.100.0, debug + release. - `cargo test --workspace -- --test-threads=4`: lib 708 passed, 0 failed, 21 ignored (2 GPU tests SKIPPED on this adapter); all other targets green, 0 failed. One full-suite run hit `coherent_buffer_sanitizes_console_flags_and_state` failing at `VirtualFree`; it passes in isolation and in the rerun and on clean `origin/main` (707/707) — flake, left untouched as a separate issue. - New test fails without the fix (exact abort from the issue: misaligned-pointer panic, exit 0xc0000409) and passes with it. The without-fix run was measured pre-rebase (base `508a0c7` + fix, test against reverted line); the with-fix result holds on this PR's head. - Review: advisor agent found nothing blocking (keep); its one nit (readable precondition) is in. **Regression run** `````` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: NVIDIA GeForce RTX 3070 Laptop GPU title: 78b7bda4 seconds: 60 exit: 0x0 frames shown: 1532 (PresentX 1532) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15259 MB `````` `````` xcl-smoke v1 commit: a4202ed12b80d5bda0069d1e36fd0aa7df996008 gpu: NVIDIA GeForce RTX 3070 Laptop GPU title: 78b7bda4 seconds: 60 exit: 0x0 frames shown: 1467 (PresentX 1467) presents per 2 s (last 3): 60 60 58 device removals: 0 crashes: 0 peak commit: 14784 MB `````` **Not tested** - AMD GPUs; other titles. - Not confirmed whether the smoked title hits the misaligned-buffer path (no `GetCustomHeapProperties` trace in the smoke logs); the run counts as a no-regression check on the touched area. - The flake above was not investigated further. **AI use** - opencode-go (muse-spark-1.3): wrote the fix, the regression test, ran the suites/smokes and this description. - Advisor review by a second agent (Opus 5.5, per operator): keep, no blocking findings.
futurepro62 commented 2026-11-24 17:06:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T16:52:55Z.


Full-suite run, since this PR has no test report yet. Tested exact head a4202ed (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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.
  • The new tests ran and passed: four_byte_aligned_return_buffer_does_not_trap.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7138351818 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1434#issuecomment-7138351818). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T16:52:55Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `a4202ed` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_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`. - The new tests ran and passed: `four_byte_aligned_return_buffer_does_not_trap`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
JorgeMJM commented 2026-11-24 17:06:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JorgeMJM on 2026-11-24T17:05:42Z.


Withdrawn by the author.

<!-- greyfinch-sync:ivall/xcl:comment:7138675727 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1434#issuecomment-7138675727). Originally posted by [JorgeMJM](https://github.com/JorgeMJM) on 2026-11-24T17:05:42Z. --- Withdrawn by the author.
upstream-sync closed this pull request 2026-11-24 18:07:33 +00:00
DavidM1911 commented 2026-11-24 19:07:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:25Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141271489 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1434#issuecomment-7141271489). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:52:25Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1424
No description provided.