D3D12.X: clamp queue slot #18 output size to 8 bytes on early callers (#104) #1378

Open
github-bot wants to merge 1 commit from github-bot/gh-1378 into main AGit
Owner

@⁠slopgobblercobbler on GitHub · 2026-11-24 15:24 UTC · original
slopgobblercobbler:fix/queue-slot18-safety → main · +68 −0 · 1 files · 1 commits · open

Summary

Fixes #104 Item 4:
Before Signal is called and QUEUE_SHIFTED is determined (e.g., during early GDK initialization when titles call ID3D12CommandQueue::GetTimestampFrequency), early callers invoke slot #18 with an 8-byte UINT64* out-param buffer.

  • When QUEUE_SHIFTED is false (and layout is not yet known), calls to slot #18 copy only the first 8 bytes of the description into the out pointer via a temporary 16-byte local buffer (desc), preventing overrun of 8-byte UINT64 buffers passed by early GetTimestampFrequency callers.
  • Adds null-pointer safety guard (if a1 != 0) ensuring null out pointers do not trigger memory writes.
  • Adds comprehensive unit test queue_slot_18_bounds_and_safety_on_early_timestamp_frequency validating canary preservation and proper dispatch under both unshifted and shifted states.

Changes

  • crates/xcl/src/hle/d3d12x/real.rs:
    • queue_method_18: use 16-byte local descriptor buffer and bounded 8-byte copy to a1 when not null.
    • Tests: queue_slot_18_bounds_and_safety_on_early_timestamp_frequency verifying 8-byte out-param bounds, canary preservation, null pointer handling, and restoration of atomic test flags.

Tested

  • Windows 11 x64, Rust 1.85+ stable (MSVC).
  • cargo test -p xcl -- real: 9 passed, 0 failed (100% pass rate).
  • Sabotage tested: writing 16 bytes directly to unshifted a1 immediately triggers canary assertion failure in synthetic test.
  • Zero trailing whitespace, GPL-2.0-only compliant, zero game data/keys.

Not Tested

  • Hardware GPU timestamp read accuracy (tested via synthetic queue COM vtable harness).

AI Use

Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity

**@⁠slopgobblercobbler** on GitHub · 2026-11-24 15:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1378) `slopgobblercobbler:fix/queue-slot18-safety` → `main` · +68 −0 · 1 files · 1 commits · open ## Summary Fixes #104 Item 4: Before `Signal` is called and `QUEUE_SHIFTED` is determined (e.g., during early GDK initialization when titles call `ID3D12CommandQueue::GetTimestampFrequency`), early callers invoke slot #18 with an 8-byte `UINT64*` out-param buffer. - When `QUEUE_SHIFTED` is false (and layout is not yet known), calls to slot #18 copy only the first 8 bytes of the description into the out pointer via a temporary 16-byte local buffer (`desc`), preventing overrun of 8-byte `UINT64` buffers passed by early `GetTimestampFrequency` callers. - Adds null-pointer safety guard (`if a1 != 0`) ensuring null out pointers do not trigger memory writes. - Adds comprehensive unit test `queue_slot_18_bounds_and_safety_on_early_timestamp_frequency` validating canary preservation and proper dispatch under both unshifted and shifted states. ## Changes - `crates/xcl/src/hle/d3d12x/real.rs`: - `queue_method_18`: use 16-byte local descriptor buffer and bounded 8-byte copy to `a1` when not null. - Tests: `queue_slot_18_bounds_and_safety_on_early_timestamp_frequency` verifying 8-byte out-param bounds, canary preservation, null pointer handling, and restoration of atomic test flags. ## Tested - Windows 11 x64, Rust 1.85+ stable (MSVC). - `cargo test -p xcl -- real`: 9 passed, 0 failed (100% pass rate). - Sabotage tested: writing 16 bytes directly to unshifted `a1` immediately triggers canary assertion failure in synthetic test. - Zero trailing whitespace, GPL-2.0-only compliant, zero game data/keys. ## Not Tested - Hardware GPU timestamp read accuracy (tested via synthetic queue COM vtable harness). ## AI Use Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:28 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 15:32 UTC · original · edited 2026-11-24 15:35 UTC

Full-suite run, since this PR has no test report yet. Tested exact head e1943b1 (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: queue_slot_18_bounds_and_safety_on_early_timestamp_frequency.
  • 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.
**@⁠futurepro62** on GitHub · 2026-11-24 15:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1378#issuecomment-7136208567) · edited 2026-11-24 15:35 UTC Full-suite run, since this PR has no test report yet. Tested exact head `e1943b1` (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: `queue_slot_18_bounds_and_safety_on_early_timestamp_frequency`. - 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 16:49 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-24 16:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/1378#issuecomment-7138268593) 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!
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:28 UTC · original

Regression run of e1943b13 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: e1943b137b5fc7ee32353422a46da4336320241b
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14818 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1378#issuecomment-7151939869) Regression run of `e1943b13` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: e1943b137b5fc7ee32353422a46da4336320241b gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1630 (PresentX 1630) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14818 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real.rs
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.
git fetch -u origin '+refs/pull/1378/head:github-bot/gh-1378'
git switch 'github-bot/gh-1378'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1378'
git switch 'github-bot/gh-1378'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1378'
git switch 'github-bot/gh-1378'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1378'
git switch 'main'
git merge --squash 'github-bot/gh-1378'
git switch 'main'
git merge --ff-only 'github-bot/gh-1378'
git switch 'main'
git merge 'github-bot/gh-1378'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.