Tests: recording-memory tests leave no fake allocator backing behind #3472

Merged
tiagonleal merged 1 commit from upstream-pr/3472 into main 2026-12-03 11:16:23 +00:00
tiagonleal commented 2026-11-29 23:15:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T23:15:57Z.


Part of #3180. A recording-memory test leaves a fake allocator backing in alloc_pool, and a later test on the same worker thread can abort the whole lib test binary.

a_recordings_memory_is_held_for_the_pc_allocator_it_is_on resets a list on the fake allocator other (a Box address + 2), so alloc_pool records the list as a user of a backing keyed by other. The test's cleanup removed the LISTS entry but never called forget_list, so forget(other) found the backing busy and only marked it retire_when_free. After the Box was freed, a later test on the same worker thread whose list reused that stack address went through on_release, then forget_list. The backing became free and sweep_release_owners dropped ID3D12CommandAllocator::from_raw(other) on a fake id. The windows-core alignment check on the vtable pointer fails there, and the panic is non-unwinding, so the whole lib test binary aborts (0xc0000409).

Seen in CI run 46300047915 on #3190, a PR that only touches alloc_pool tests: abort in hle::d3d12x::list_x::tests::wait64_flags_do_not_mask_the_recorded_counter, "misaligned pointer dereference: address must be a multiple of 0x8 but is 0x1d1adc819a2". The sighting is listed in #3180.

What is in it

  • list_x.rs: the two reset tests clean up with on_release(key) before forgetting the fake allocators, like their neighbours; the recording-memory test asserts that alloc_pool keeps nothing keyed by its fake ids
  • alloc_pool.rs: new #[cfg(test)] helpers tracks_for_test (does STATE still key anything by a fake id) and drop_synthetic_for_test (drop a fake backing and its users' recordings without releasing it)
  • bind.rs: the test that leaves a recording on the fake busy allocator drops that backing with drop_synthetic_for_test
  • +25/-2, three files; everything is inside #[cfg(test)], no runtime behaviour changes

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 5070 Ti 16 GB (driver 617.42), AMD Ryzen 7 9800X3D, 32 GB RAM, rustc 1.100.0, debug
  • cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 on head be8bce2d: 2841 passed, 0 failed, 51 ignored (24 SKIPPED lines: 22 no wave64, 2 no heap windows; the same 24 in both logs). main f97120dc on the same machine: 2841 passed, 0 failed, 51 ignored.
  • On the previous head 7230332c (same diff, before the rebase), with the old cleanup line put back in that one test (LISTS.lock().unwrap().as_mut().unwrap().remove(&key); in place of on_release(key);), cargo test -p xcl --lib hle::d3d12x::list_x::tests::a_recordings_memory_is_held_for_the_pc_allocator_it_is_on -- --exact --test-threads=1 fails on the new assertion with left: [true, false, false, true]: the list and the fake allocator other are still keyed in alloc_pool. With the fix the same command passes.

Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e (a retail title), release builds of both commits, main f97120dc and this PR's head be8bce2d, one run each. A second run of main after the PR runs gave 1680 frames.

main (f97120dc):

xcl-smoke v1
commit: f97120dc196ca05e7f47e919d3675f7d5a2b478a
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1635 (PresentX 1635)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15366 MB

This PR (be8bce2d):

xcl-smoke v1
commit: be8bce2d03a0d5ec485ed28ac236601f0d25f7fa
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1681 (PresentX 1681)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15799 MB

Not tested

  • The abort itself was not reproduced on demand. It depends on which worker thread and stack slot a later test gets.
  • Other modules that use fake allocator ids against alloc_pool (device_x, pso_async, the VRAM tests) were not audited.
  • AMD.

AI use

  • Claude Code with Claude Opus 5.5 wrote the change and Claude Fable 5.2 directed the diagnosis, ran the tests and wrote this description.
<!-- greyfinch-sync:ivall/xcl:issue:5556212402 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3472). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-29T23:15:57Z. --- Part of #3180. A recording-memory test leaves a fake allocator backing in `alloc_pool`, and a later test on the same worker thread can abort the whole lib test binary. `a_recordings_memory_is_held_for_the_pc_allocator_it_is_on` resets a list on the fake allocator `other` (a Box address + 2), so `alloc_pool` records the list as a user of a backing keyed by `other`. The test's cleanup removed the `LISTS` entry but never called `forget_list`, so `forget(other)` found the backing busy and only marked it `retire_when_free`. After the Box was freed, a later test on the same worker thread whose list reused that stack address went through `on_release`, then `forget_list`. The backing became free and `sweep_release_owners` dropped `ID3D12CommandAllocator::from_raw(other)` on a fake id. The `windows-core` alignment check on the vtable pointer fails there, and the panic is non-unwinding, so the whole lib test binary aborts (0xc0000409). Seen in CI run 46300047915 on #3190, a PR that only touches `alloc_pool` tests: abort in `hle::d3d12x::list_x::tests::wait64_flags_do_not_mask_the_recorded_counter`, "misaligned pointer dereference: address must be a multiple of 0x8 but is 0x1d1adc819a2". The sighting is listed in #3180. **What is in it** - `list_x.rs`: the two reset tests clean up with `on_release(key)` before forgetting the fake allocators, like their neighbours; the recording-memory test asserts that `alloc_pool` keeps nothing keyed by its fake ids - `alloc_pool.rs`: new `#[cfg(test)]` helpers `tracks_for_test` (does `STATE` still key anything by a fake id) and `drop_synthetic_for_test` (drop a fake backing and its users' recordings without releasing it) - `bind.rs`: the test that leaves a recording on the fake `busy` allocator drops that backing with `drop_synthetic_for_test` - +25/-2, three files; everything is inside `#[cfg(test)]`, no runtime behaviour changes **Tested** - Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 5070 Ti 16 GB (driver 617.42), AMD Ryzen 7 9800X3D, 32 GB RAM, rustc 1.100.0, debug - `cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4` on head `be8bce2d`: 2841 passed, 0 failed, 51 ignored (24 `SKIPPED` lines: 22 `no wave64`, 2 `no heap windows`; the same 24 in both logs). `main` `f97120dc` on the same machine: 2841 passed, 0 failed, 51 ignored. - On the previous head `7230332c` (same diff, before the rebase), with the old cleanup line put back in that one test (`LISTS.lock().unwrap().as_mut().unwrap().remove(&key);` in place of `on_release(key);`), `cargo test -p xcl --lib hle::d3d12x::list_x::tests::a_recordings_memory_is_held_for_the_pc_allocator_it_is_on -- --exact --test-threads=1` fails on the new assertion with `left: [true, false, false, true]`: the list and the fake allocator `other` are still keyed in `alloc_pool`. With the fix the same command passes. **Regression run** `scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e` (a retail title), release builds of both commits, `main` `f97120dc` and this PR's head `be8bce2d`, one run each. A second run of `main` after the PR runs gave 1680 frames. `main` (`f97120dc`): ``` xcl-smoke v1 commit: f97120dc196ca05e7f47e919d3675f7d5a2b478a gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1635 (PresentX 1635) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15366 MB ``` This PR (`be8bce2d`): ``` xcl-smoke v1 commit: be8bce2d03a0d5ec485ed28ac236601f0d25f7fa gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1681 (PresentX 1681) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15799 MB ``` **Not tested** - The abort itself was not reproduced on demand. It depends on which worker thread and stack slot a later test gets. - Other modules that use fake allocator ids against `alloc_pool` (`device_x`, `pso_async`, the VRAM tests) were not audited. - AMD. **AI use** - Claude Code with Claude Opus 5.5 wrote the change and Claude Fable 5.2 directed the diagnosis, ran the tests and wrote this description.
AAsobu commented 2026-11-30 23:05:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by AAsobu on 2026-11-30T23:05:11Z.


merge-check
base: 86e86fcb33
head: be8bce2d03
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2889 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps), the same counts as main on this machine; failing: none.
review: none. Read the whole diff (+25/-2): everything is in #[cfg(test)] code (alloc_pool.rs test helpers, one line in a bind.rs test, the two reset tests in list_x.rs), so no runtime path changes. drop_synthetic_for_test removes the fake backing and its users' recordings without calling a release on the fake id, which is the point.

  • Checked that the new assertion catches the leak: with the old cleanup line put back in a_recordings_memory_is_held_for_the_pc_allocator_it_is_on (LISTS...remove(&key) in place of on_release(key)), cargo test -p xcl --lib hle::d3d12x::list_x::tests::a_recordings_memory_is_held_for_the_pc_allocator_it_is_on -- --exact --test-threads=1 fails with left: [true, false, false, true] ("the test leaves nothing keyed by its fake ids"), as in the description; with the PR's line it passes.
  • The abort this fixes also happened on this machine before the PR: a full suite run on main (ff0c364b) + an unrelated test-only PR, with a second suite running at the same time by mistake, aborted the lib binary in hle::d3d12x::list_x::tests::wait64_flags_do_not_mask_the_recorded_counter with "misaligned pointer dereference: address must be a multiple of 0x8 but is 0x1b967876262" in windows-core-0.62.2\src\interface.rs:41, exit 0xc0000409: the same test, message and exit code as the CI sighting in the description.
    performance: none (test code only). The abort is rare, so repeated runs say little: the lib test binary (--test-threads=4) ran 5 times each for main and this merge, alternated: no abort in any of the 10, and none in 12 earlier runs of main's lib binary here (17 in all); the one abort of this kind I have is the double full-suite run above. One of the 5 main runs had the known flaky title_textures cascade (12 failures after a poisoned lock, starting with a_placed_texture_gets_the_pages_of_a_level_with_its_texels), which this PR does not touch.
    verdict: safe to merge
    hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5), results checked by me
<!-- greyfinch-sync:ivall/xcl:comment:7294690900 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3472#issuecomment-7294690900). Originally posted by [AAsobu](https://github.com/AAsobu) on 2026-11-30T23:05:11Z. --- merge-check base: 86e86fcb33f94fa5d0c809d9b50af7b84bf49cce head: be8bce2d03a0d5ec485ed28ac236601f0d25f7fa merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2889 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps), the same counts as `main` on this machine; failing: none. review: none. Read the whole diff (+25/-2): everything is in `#[cfg(test)]` code (`alloc_pool.rs` test helpers, one line in a `bind.rs` test, the two reset tests in `list_x.rs`), so no runtime path changes. `drop_synthetic_for_test` removes the fake backing and its users' recordings without calling a release on the fake id, which is the point. - Checked that the new assertion catches the leak: with the old cleanup line put back in `a_recordings_memory_is_held_for_the_pc_allocator_it_is_on` (`LISTS...remove(&key)` in place of `on_release(key)`), `cargo test -p xcl --lib hle::d3d12x::list_x::tests::a_recordings_memory_is_held_for_the_pc_allocator_it_is_on -- --exact --test-threads=1` fails with `left: [true, false, false, true]` ("the test leaves nothing keyed by its fake ids"), as in the description; with the PR's line it passes. - The abort this fixes also happened on this machine before the PR: a full suite run on `main` (`ff0c364b`) + an unrelated test-only PR, with a second suite running at the same time by mistake, aborted the lib binary in `hle::d3d12x::list_x::tests::wait64_flags_do_not_mask_the_recorded_counter` with "misaligned pointer dereference: address must be a multiple of 0x8 but is 0x1b967876262" in `windows-core-0.62.2\src\interface.rs:41`, exit 0xc0000409: the same test, message and exit code as the CI sighting in the description. performance: none (test code only). The abort is rare, so repeated runs say little: the lib test binary (`--test-threads=4`) ran 5 times each for `main` and this merge, alternated: no abort in any of the 10, and none in 12 earlier runs of `main`'s lib binary here (17 in all); the one abort of this kind I have is the double full-suite run above. One of the 5 `main` runs had the known flaky `title_textures` cascade (12 failures after a poisoned lock, starting with `a_placed_texture_gets_the_pages_of_a_level_with_its_texels`), which this PR does not touch. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5), results checked by me
Foniass commented 2026-12-01 09:11:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:11:55Z.


merge-check
base: 7d86c5d2b7
head: be8bce2d03
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (alloc_pool.rs #[cfg(test)] helpers, bind.rs and list_x.rs tests). The leak is real on main: list_x.rs ~8132 / ~8172 only remove the LISTS entry, so forget only marks the busy fake backing retire_when_free (alloc_pool.rs ~1230-1236), and a later forget_list on a reused address makes sweep_release_owners call from_raw on the fake id (~321), which can abort the test binary. Calling on_release(key) matches the neighbouring tests. Findings (minor): the new "nothing keyed by fake ids" assertion is only in a_recordings_memory_is_held_for_the_pc_allocator_it_is_on (~8166), while the 0x111 / 0x333 reset test (~8117) and the bind test (~7930) get the cleanup without it; tracks_for_test also looks up allocator ids in of_list, keyed by list (harmless). Fine: everything is inside #[cfg(test)], no assertion is weakened (the bind.rs cleanup runs after the values are captured), and the PR shows its new assertion failing with the old cleanup line. No smoke run here: test-only.
performance: no smoke run (the default path doesn't reach this change); not measured. Test-only: no runtime path changes.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7306353272 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3472#issuecomment-7306353272). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:11:55Z. --- merge-check base: 7d86c5d2b7845695031eeea1327aa81b6c439323 head: be8bce2d03a0d5ec485ed28ac236601f0d25f7fa merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (alloc_pool.rs `#[cfg(test)]` helpers, bind.rs and list_x.rs tests). The leak is real on main: `list_x.rs` ~8132 / ~8172 only remove the `LISTS` entry, so `forget` only marks the busy fake backing `retire_when_free` (`alloc_pool.rs` ~1230-1236), and a later `forget_list` on a reused address makes `sweep_release_owners` call `from_raw` on the fake id (~321), which can abort the test binary. Calling `on_release(key)` matches the neighbouring tests. Findings (minor): the new "nothing keyed by fake ids" assertion is only in `a_recordings_memory_is_held_for_the_pc_allocator_it_is_on` (~8166), while the 0x111 / 0x333 reset test (~8117) and the bind test (~7930) get the cleanup without it; `tracks_for_test` also looks up allocator ids in `of_list`, keyed by list (harmless). Fine: everything is inside `#[cfg(test)]`, no assertion is weakened (the bind.rs cleanup runs after the values are captured), and the PR shows its new assertion failing with the old cleanup line. No smoke run here: test-only. performance: no smoke run (the default path doesn't reach this change); not measured. Test-only: no runtime path changes. verdict: safe to merge hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Foniass commented 2026-12-01 09:59:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:59:05Z.


Triage (#1607) – head be8bce2

#3183 and #3190 are also for #3180 but fix other flaky tests (a serialised pipeline test in shaders.rs, and alloc_pool checks that STATE is held by the caller). This one fixes the fake allocator backings left behind by the list_x reset tests and the bind.rs busy-allocator test. These are separate changes, not duplicates.
The changes are test-only (#[cfg(test)] helpers in alloc_pool.rs, on_release(key) in place of the bare LISTS removal, like the neighbouring tests do). No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7307495073 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3472#issuecomment-7307495073). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:59:05Z. --- **Triage (#1607)** – head be8bce2 #3183 and #3190 are also for #3180 but fix other flaky tests (a serialised pipeline test in `shaders.rs`, and `alloc_pool` checks that `STATE` is held by the caller). This one fixes the fake allocator backings left behind by the `list_x` reset tests and the `bind.rs` busy-allocator test. These are separate changes, not duplicates. The changes are test-only (`#[cfg(test)]` helpers in `alloc_pool.rs`, `on_release(key)` in place of the bare `LISTS` removal, like the neighbouring tests do). No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
bmjask commented 2026-12-02 14:13:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:13:25Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7348189268 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3472#issuecomment-7348189268). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:13:25Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Kalmarv commented 2026-12-02 23:42:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T23:42:34Z.


CI evidence for this fix, from a survey of the 60 most recent failed Build and test (Windows, no GPU) runs (2026-12-02). Four jobs on branches unrelated to list_x ended with misaligned pointer dereference: address must be a multiple of 0x8 but is 0x…2 (exit 0xc0000409) inside a list_x::tests::wait64_* test:

Each address is a 16-aligned heap address + 2, which is the fake allocator (Box+2) that a_recordings_memory_is_held_for_the_pc_allocator_it_is_on and reset_commits_state_only_after_native_success_and_always_restores_vtable leave in alloc_pool. On an RTX 5070 Ti, adding alloc_pool::forget_list(key) (what a later test's on_release at the same reused stack address does) to the end of the unchanged test reproduces the same abort; with on_release(key) as in this PR, the test passes.

Written with Claude Code (Claude Opus 5.5) from the CI logs and that local run.

<!-- greyfinch-sync:ivall/xcl:comment:7362330792 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3472#issuecomment-7362330792). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T23:42:34Z. --- CI evidence for this fix, from a survey of the 60 most recent failed `Build and test (Windows, no GPU)` runs (2026-12-02). Four jobs on branches unrelated to `list_x` ended with `misaligned pointer dereference: address must be a multiple of 0x8 but is 0x…2` (exit 0xc0000409) inside a `list_x::tests::wait64_*` test: - [143704237457](https://github.com/xcl-dev/xcl/actions/runs/46948810043/job/143704237457) (`pr/waterfall-1dword`) - [143220589420](https://github.com/xcl-dev/xcl/actions/runs/46810914505/job/143220589420) (`contrib/up-null-vb-ib-view`) - [143207368637](https://github.com/xcl-dev/xcl/actions/runs/46806987143/job/143207368637) (`pr/dxil-helper-outlining`) - [143141030643](https://github.com/xcl-dev/xcl/actions/runs/46787464138/job/143141030643) (`d3d12x/budget-l0-spillover`) Each address is a 16-aligned heap address + 2, which is the fake allocator (`Box`+2) that `a_recordings_memory_is_held_for_the_pc_allocator_it_is_on` and `reset_commits_state_only_after_native_success_and_always_restores_vtable` leave in `alloc_pool`. On an RTX 5070 Ti, adding `alloc_pool::forget_list(key)` (what a later test's `on_release` at the same reused stack address does) to the end of the unchanged test reproduces the same abort; with `on_release(key)` as in this PR, the test passes. Written with Claude Code (Claude Opus 5.5) from the CI logs and that local run.
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!3472
No description provided.