Skip to content

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

Open
tiagonleal wants to merge 1 commit into
xcl-dev:mainfrom
tiagonleal:tests/recording-memory-test-leaves-no-backing
Open

tiagonleal wants to merge 1 commit into
xcl-dev:mainfrom
tiagonleal:tests/recording-memory-test-leaves-no-backing

Conversation

@tiagonleal

@tiagonleal tiagonleal commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
a_recordings_memory_is_held_for_the_pc_allocator_it_is_on reset its
stack-address list on the fake allocator `other` (a Box address + 2),
which made alloc_pool record the list as a user of a backing keyed by
`other`. Cleanup removed the LISTS entry but never forget_list'ed the
list, so forget(other) found the backing busy and only marked it
retire_when_free. After the Box was freed, any later test on the same
worker whose list reused that stack slot called on_release ->
forget_list, the backing became free, and sweep_release_owners dropped
ID3D12CommandAllocator::from_raw(other): windows-core checks the vtable
pointer alignment and the non-unwinding panic aborted the whole lib
test binary (0xc0000409), seen in
wait64_flags_do_not_mask_the_recorded_counter.

Both reset tests in list_x now clean up with on_release(key) before
forgetting the fake allocators, like their neighbours, and the
recording-memory test asserts that alloc_pool keeps nothing keyed by
its fake ids. The bind test that leaves a recording on the fake `busy`
allocator drops that backing without releasing it, as the alloc_pool
tests do with their synthetic backings.
@AAsobu

AAsobu commented Nov 30, 2026

Copy link
Copy Markdown

merge-check
base: 86e86fc
head: be8bce2
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

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 7d86c5d
head: be8bce2
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.

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants