d3d12_xs tests: three --lib tests that fail or crash on a release build (dangling temporary, function address, stale map entry) #276

Closed
QuentinDanblon wants to merge 3 commits from upstream-pr/276 into main
QuentinDanblon commented 2026-11-23 10:53:39 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-23T10:53:39Z.


Library / area: d3d12_xs, tests only (pso_xrec.rs test module, device_console_fix.rs test module, dbcount_tests.rs)

Exports changed (exports.txt rows): none

Source of the behaviour: none needed, no runtime behaviour changes. Three tests of the --lib suite fail or kill the test process on this PC (RTX 5090, Windows 11, release build). CI does not run them: rust.yml only runs cargo check for d3d12_xs.

Three commits, one per test. Each fix is in the test, 3 files, +3 -3.

1. pso_xrec::tests::unknown_root_signatures_ext_entries_and_cached_blobs_are_not_recorded (ff387bb)

The whole test process died with an access violation, 3 runs of 3 with --exact. Under cdb the fault is in pso_xrec::capture at pso_xrec.rs:294, reading the semantic name of an input-layout element.

The test built its descriptor with gfx_desc(&vs, &ps, &[elem(..)], ..) inside a let. The element array is a temporary dropped at the end of that statement, so the descriptor kept a dangling pointer. The first three captures return before they read the input layout; only the last one dereferenced it.

capture is right to read through the title's pointer: the D3D12 create call requires the arrays to be valid for the duration of the call. The array is now bound to a local that outlives every capture. 5 runs of 5 pass.

2. device_console_fix::tests::console_heap_properties_create_on_pc_through_every_wrapped_path (dd6d6f7)

Failed on every run at device_console_fix.rs:384: the test compared slot 26 of the wrapped vtable with get_custom_heap_properties_x as usize, and the two addresses differed.

In cdb, x *!*get_custom_heap_properties_x* lists two symbols of that name in the release test binary. The build holds two copies of that small function, and Rust does not guarantee one address per function. The wrapper does install our function; the test compared two copies of it.

The address check is removed. The test still calls slot 26 with a sentinel-filled struct and requires the console values for heap types 1, 2 and 3, then checks that the PC runtime rejects those values unwrapped and that every wrapped create path accepts them.

Checked that the remaining assertions catch a slot 26 that is not replaced: with slot 26 taken from the unwrapped device (local change, not committed) the test process dies with an access violation, because the console order of the arguments is not the PC one.

3. dbcount::tests::translated_pixel_shaders_with_uavs_keep_their_source (a7ab19e)

Failed in full runs with --test-threads=1: 2 runs of 2 on the two commits above. The test asserted that PS_SRC holds no entry at the address of a pixel shader without UAVs. PS_SRC is process-wide, keyed by the address of the bytecode, and never shrinks, so an earlier test can leave an entry at an address the allocator later gives to this test.

Measured with a probe in place of the assertion, 2 runs of 2: the entry at the address of the plain shader had length 3304, the plain shader 2512 bytes, the UAV shader of this test 3152 bytes. It belongs to neither.

The assertion now uses the rule strip_ps uses in production, which reads an entry only when its length and hash match the bytecode. I did not look for which earlier test notes that entry.

Tests

On a7ab19e (base de1e1da), RTX 5090 PC, Windows 11:

  • cargo test -p d3d12_xs --release --lib -- --test-threads=1: 3 runs, each 662 passed, 1 failed, 71 ignored.
  • The remaining failure is xs_exports::console_fixed_tests::fixed_result_dxgix_exports_match_every_console_d3d12_xs. It needs a console d3d12_xs.dll, which I do not have. Not touched.
  • pr_gate.py --base origin/main: 0 problems.

Not covered, not claimed

  • Other tests compare a vtable slot with a function address in the same way and pass today: cl_console_fix.rs:413-420, console_slots.rs:591-593, cl2_state.rs:2398. The same duplication could break them in another build. I did not change them.

  • The second fix was checked on the RTX 5090 only.

  • Whether these tests behave the same on your machine or in a debug build is not known to me.

  • cargo test -p d3d12_xs passes for what is listed above

  • No game or console files and no binaries included

  • No fake success; nothing in the runtime changes

🤖 Generated with Claude Code

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6557666738 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/276). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-23T10:53:39Z. --- **Library / area:** `d3d12_xs`, tests only (`pso_xrec.rs` test module, `device_console_fix.rs` test module, `dbcount_tests.rs`) **Exports changed (exports.txt rows):** none **Source of the behaviour:** none needed, no runtime behaviour changes. Three tests of the `--lib` suite fail or kill the test process on this PC (RTX 5090, Windows 11, release build). CI does not run them: `rust.yml` only runs `cargo check` for `d3d12_xs`. Three commits, one per test. Each fix is in the test, 3 files, +3 -3. ### 1. `pso_xrec::tests::unknown_root_signatures_ext_entries_and_cached_blobs_are_not_recorded` (`ff387bb`) The whole test process died with an access violation, 3 runs of 3 with `--exact`. Under cdb the fault is in `pso_xrec::capture` at `pso_xrec.rs:294`, reading the semantic name of an input-layout element. The test built its descriptor with `gfx_desc(&vs, &ps, &[elem(..)], ..)` inside a `let`. The element array is a temporary dropped at the end of that statement, so the descriptor kept a dangling pointer. The first three captures return before they read the input layout; only the last one dereferenced it. `capture` is right to read through the title's pointer: the D3D12 create call requires the arrays to be valid for the duration of the call. The array is now bound to a local that outlives every capture. 5 runs of 5 pass. ### 2. `device_console_fix::tests::console_heap_properties_create_on_pc_through_every_wrapped_path` (`dd6d6f7`) Failed on every run at `device_console_fix.rs:384`: the test compared slot 26 of the wrapped vtable with `get_custom_heap_properties_x as usize`, and the two addresses differed. In cdb, `x *!*get_custom_heap_properties_x*` lists two symbols of that name in the release test binary. The build holds two copies of that small function, and Rust does not guarantee one address per function. The wrapper does install our function; the test compared two copies of it. The address check is removed. The test still calls slot 26 with a sentinel-filled struct and requires the console values for heap types 1, 2 and 3, then checks that the PC runtime rejects those values unwrapped and that every wrapped create path accepts them. Checked that the remaining assertions catch a slot 26 that is not replaced: with slot 26 taken from the unwrapped device (local change, not committed) the test process dies with an access violation, because the console order of the arguments is not the PC one. ### 3. `dbcount::tests::translated_pixel_shaders_with_uavs_keep_their_source` (`a7ab19e`) Failed in full runs with `--test-threads=1`: 2 runs of 2 on the two commits above. The test asserted that `PS_SRC` holds no entry at the address of a pixel shader without UAVs. `PS_SRC` is process-wide, keyed by the address of the bytecode, and never shrinks, so an earlier test can leave an entry at an address the allocator later gives to this test. Measured with a probe in place of the assertion, 2 runs of 2: the entry at the address of the plain shader had length 3304, the plain shader 2512 bytes, the UAV shader of this test 3152 bytes. It belongs to neither. The assertion now uses the rule `strip_ps` uses in production, which reads an entry only when its length and hash match the bytecode. I did not look for which earlier test notes that entry. ### Tests On `a7ab19e` (base `de1e1da`), RTX 5090 PC, Windows 11: - `cargo test -p d3d12_xs --release --lib -- --test-threads=1`: 3 runs, each 662 passed, 1 failed, 71 ignored. - The remaining failure is `xs_exports::console_fixed_tests::fixed_result_dxgix_exports_match_every_console_d3d12_xs`. It needs a console `d3d12_xs.dll`, which I do not have. Not touched. - `pr_gate.py --base origin/main`: 0 problems. ### Not covered, not claimed - Other tests compare a vtable slot with a function address in the same way and pass today: `cl_console_fix.rs:413-420`, `console_slots.rs:591-593`, `cl2_state.rs:2398`. The same duplication could break them in another build. I did not change them. - The second fix was checked on the RTX 5090 only. - Whether these tests behave the same on your machine or in a debug build is not known to me. - [x] `cargo test -p d3d12_xs` passes for what is listed above - [x] No game or console files and no binaries included - [x] No fake success; nothing in the runtime changes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
omonkeyz commented 2026-11-23 13:45:15 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-23T13:45:15Z.


Applied locally on main with your authorship kept (cherry-picked, c40dd17); tests pass in a sandbox. It ships in the next release; this PR will be closed when that is pushed. Thanks.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7102979565 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/276#issuecomment-7102979565). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-23T13:45:15Z. --- Applied locally on main with your authorship kept (cherry-picked, c40dd17); tests pass in a sandbox. It ships in the next release; this PR will be closed when that is pushed. Thanks.
omonkeyz commented 2026-11-25 13:09:03 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-25T13:09:03Z.


Applied on main in c40dd17 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7163362594 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/276#issuecomment-7163362594). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:09:03Z. --- Applied on main in c40dd17 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

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
omonkeyz/xbox-emulator!276
No description provided.