Tests: release placed descriptor heaps before reusing their memory #2260

Merged
andrewpozdnakov7-jpg merged 1 commit from upstream-pr/2262 into main 2026-11-25 21:56:06 +00:00
andrewpozdnakov7-jpg commented 2026-11-25 09:17:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T09:17:32Z.


Fixes #2252.

The placed-heap test overwrote its first COM handle and then dropped the backing memory. Its still-registered heap could intercept writes when another fixture allocated descriptors at that address. That left the new heap's host descriptors uninitialized. Release both fixture heaps before returning and check that a descriptor write at a reused address reaches the new heap.

  • On main 940d32f, the new address-reuse assertion fails because the new heap receives no descriptor write. It passes with the release calls.
  • An observation-only build of main reproduced the reported 0 instead of 1064 in 3 of 63 parallel victory-gpu runs on WARP. In all three, the heap tracked zero viewed buffer ranges even though both title-side view records were present.
  • With the fix, the full victory-gpu suite passed on WARP with 146 passed and 2 ignored. Both bindless tests and the full suite then passed in all 85 additional parallel runs (16 test threads). Clippy with default and diagnostics features and the staged policy check passed.

Please preserve the Git author if reapplying this change. If its code or test is folded into another commit, please add:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601156345 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2262). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T09:17:32Z. --- Fixes #2252. The placed-heap test overwrote its first COM handle and then dropped the backing memory. Its still-registered heap could intercept writes when another fixture allocated descriptors at that address. That left the new heap's host descriptors uninitialized. Release both fixture heaps before returning and check that a descriptor write at a reused address reaches the new heap. - On main 940d32f, the new address-reuse assertion fails because the new heap receives no descriptor write. It passes with the release calls. - An observation-only build of main reproduced the reported 0 instead of 1064 in 3 of 63 parallel victory-gpu runs on WARP. In all three, the heap tracked zero viewed buffer ranges even though both title-side view records were present. - With the fix, the full victory-gpu suite passed on WARP with 146 passed and 2 ignored. Both bindless tests and the full suite then passed in all 85 additional parallel runs (16 test threads). Clippy with default and diagnostics features and the staged policy check passed. Please preserve the Git author if reapplying this change. If its code or test is folded into another commit, please add: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic tests only.
DenRakEiw commented 2026-11-25 10:07:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T09:23:30Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib descriptor::tests:: — 5 passed, 0 failed
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix releasing placed descriptor heaps before reusing their backing memory in tests. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6054871996 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2262#pullrequestreview-6054871996). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T09:23:30Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib descriptor::tests::` — 5 passed, 0 failed - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean fix releasing placed descriptor heaps before reusing their backing memory in tests. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 10:07:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T09:35:34Z.

Review: COMMENTED


Tests: release placed descriptor heaps before reusing their addresses; Windows-only reuse check added. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Test-only fix for cross-test heap-address aliasing.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055073177 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2262#pullrequestreview-6055073177). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:35:34Z. **Review:** COMMENTED --- Tests: release placed descriptor heaps before reusing their addresses; Windows-only reuse check added. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Test-only fix for cross-test heap-address aliasing.
eazyves commented 2026-11-25 11:05:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by eazyves on 2026-11-25T10:42:42Z.


On an RX 9070 XT (RDNA4), hardware adapter: main 940d32f fails in 10 of 250 runs, this PR (d183e7c, same base) in 0 of 250.

Each run is the built victory-gpu lib test binary, default threads, default features, one process after another.

failing test main this PR
bindless::tests::heap_views_are_current (0 instead of 1064) 4 0
bindless::tests::heap_views_follow_writes_through_another_mapping (0 instead of 1064) 3 0
draw::tests::root_views_reach_their_copy_and_read_zeros_past_it (draw.rs:2024, all zeros instead of 20480..) 2 0
shadow::tests::marked_pages_go_back_by_the_bytes_the_gpu_changed (shadow.rs:1136, 0 instead of 170) 1 0

An earlier 80 runs of main had 5 such failures: 2 heap_views_follow_..., 2 root_views_reach_..., and 1 descriptor::host::tests::dynamic_slots_are_held_until_released.

So the two bindless tests are the ones I can tie to this fix. The other three are rarer: 0 in 250 fits this fix covering them, but it is too few to say so, and I have not traced them.

Setup: RX 9070 XT, driver 32.0.32029.2010, Ryzen 7 5800X3D, Windows 11 26200, Rust 1.98.1. The tests ran from a service session (session 0). No game data. AI-assisted (Claude Code); run on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160069886 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2262#issuecomment-7160069886). Originally posted by [eazyves](https://github.com/eazyves) on 2026-11-25T10:42:42Z. --- **On an RX 9070 XT (RDNA4), hardware adapter: `main` 940d32f fails in 10 of 250 runs, this PR (d183e7c, same base) in 0 of 250.** Each run is the built `victory-gpu` lib test binary, default threads, default features, one process after another. | failing test | `main` | this PR | |---|---|---| | `bindless::tests::heap_views_are_current` (0 instead of 1064) | 4 | 0 | | `bindless::tests::heap_views_follow_writes_through_another_mapping` (0 instead of 1064) | 3 | 0 | | `draw::tests::root_views_reach_their_copy_and_read_zeros_past_it` (draw.rs:2024, all zeros instead of 20480..) | 2 | 0 | | `shadow::tests::marked_pages_go_back_by_the_bytes_the_gpu_changed` (shadow.rs:1136, 0 instead of 170) | 1 | 0 | An earlier 80 runs of `main` had 5 such failures: 2 `heap_views_follow_...`, 2 `root_views_reach_...`, and 1 `descriptor::host::tests::dynamic_slots_are_held_until_released`. So the two `bindless` tests are the ones I can tie to this fix. The other three are rarer: 0 in 250 fits this fix covering them, but it is too few to say so, and I have not traced them. Setup: RX 9070 XT, driver 32.0.32029.2010, Ryzen 7 5800X3D, Windows 11 26200, Rust 1.98.1. The tests ran from a service session (session 0). No game data. AI-assisted (Claude Code); run on my machine.
eazyves commented 2026-11-25 13:02:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by eazyves on 2026-11-25T12:17:11Z.


Follow-up with more runs, same two builds and machine as above: this PR now has 0 failures in 1,000 runs (250 + 750).

The second series on main was cut off before its end, so I only know it had at most 750 runs. In it:

failing test failures on main (≤ 750 runs) this PR (750 runs)
heap_views_are_current 7 0
heap_views_follow_writes_through_another_mapping 6 0
root_views_reach_their_copy_and_read_zeros_past_it 6 0
dynamic_slots_are_held_until_released 1 0
frame::tests::waits_end_on_ticks_and_count_frames 1 0

That changes one thing I wrote: root_views_reach_... now has 10 failures on main (2 + 2 + 6, in at most 1,080 runs) against 0 in 1,000 here, so this fix most likely covers it too. I have not traced why. The last two are too rare to say, and marked_pages_go_back_... did not fail again.

Correction: other builds ran on the machine during part of the second main series, so its conditions differed from this PR's series. The first 250 against 250 is the cleaner comparison (10 against 0).

AI-assisted (Claude Code); run on my machine. No game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162168901 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2262#issuecomment-7162168901). Originally posted by [eazyves](https://github.com/eazyves) on 2026-11-25T12:17:11Z. --- Follow-up with more runs, same two builds and machine as above: **this PR now has 0 failures in 1,000 runs** (250 + 750). The second series on `main` was cut off before its end, so I only know it had at most 750 runs. In it: | failing test | failures on `main` (≤ 750 runs) | this PR (750 runs) | |---|---|---| | `heap_views_are_current` | 7 | 0 | | `heap_views_follow_writes_through_another_mapping` | 6 | 0 | | `root_views_reach_their_copy_and_read_zeros_past_it` | 6 | 0 | | `dynamic_slots_are_held_until_released` | 1 | 0 | | `frame::tests::waits_end_on_ticks_and_count_frames` | 1 | 0 | That changes one thing I wrote: `root_views_reach_...` now has 10 failures on `main` (2 + 2 + 6, in at most 1,080 runs) against 0 in 1,000 here, so this fix most likely covers it too. I have not traced why. The last two are too rare to say, and `marked_pages_go_back_...` did not fail again. **Correction:** other builds ran on the machine during part of the second `main` series, so its conditions differed from this PR's series. The first 250 against 250 is the cleaner comparison (10 against 0). AI-assisted (Claude Code); run on my machine. No game data.
Marvisak commented 2026-11-25 13:02:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:45:18Z.


Automated triage for the maintainers.

Merge candidate (test fix). The placed-heap test in crates/victory-gpu/src/descriptor.rs left its placed descriptor heaps registered after it finished. Another test whose heap later reused that address could then have its descriptor writes routed to the stale registration. The PR releases both heaps. On Windows it also checks that a heap created again at the same address receives a descriptor write (pending == [0]).

The evidence is strong. On an RX 9070 XT, main showed intermittent failures in several bindless/draw tests (about 1 in 50 runs), and this PR showed none in 1,000 runs. CI check passes, and the branch merges cleanly. This likely explains the flaky bindless::tests failure reported as #2252.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162809147 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2262#issuecomment-7162809147). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T12:45:18Z. --- <!-- victory-triage v1 head=d183e7c9b920f45c06f4c5bed4c24298463f7f12 verdict=merge-candidate at=2026-11-25T12:47:00Z --> Automated triage for the maintainers. **Merge candidate (test fix).** The placed-heap test in `crates/victory-gpu/src/descriptor.rs` left its placed descriptor heaps registered after it finished. Another test whose heap later reused that address could then have its descriptor writes routed to the stale registration. The PR releases both heaps. On Windows it also checks that a heap created again at the same address receives a descriptor write (`pending == [0]`). The evidence is strong. On an RX 9070 XT, `main` showed intermittent failures in several `bindless`/`draw` tests (about 1 in 50 runs), and this PR showed none in 1,000 runs. CI `check` passes, and the branch merges cleanly. This likely explains the flaky `bindless::tests` failure reported as #2252. --- _Generated by [Claude Code](https://claude.ai/code)_
fyernald commented 2026-11-25 17:03:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-25T16:28:25Z.

Review: APPROVED


The cause checks out in the code on current main (67e8ae1). create_heap registers every shader-visible heap in SHADER_HEAPS, and only Heap::drop takes the entry out. placed_heaps_start_at_the_title_memory never released its placed heap, and its Vec was freed at the end of the test. That left a live registration over freed memory, which a later heap at the same address loses its writes to.

Merged onto 67e8ae1 (no conflicts): the test passes, including the new reuse check. The full victory-gpu lib binary was run 50 times in parallel (Windows 10 19045, RTX 3080) with no bindless::tests::heap_views_* failure. To be fair to the numbers: I couldn't reproduce that flake on plain main on this machine either (0 in 300+ runs). So my support here rests on the deterministic reuse check and the code, not on a before/after rate.

<!-- greyfinch-sync:Marvisak/VIctory:review:6061165377 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2262#pullrequestreview-6061165377). Originally posted by [fyernald](https://github.com/fyernald) on 2026-11-25T16:28:25Z. **Review:** APPROVED --- The cause checks out in the code on current `main` (`67e8ae1`). `create_heap` registers every shader-visible heap in `SHADER_HEAPS`, and only `Heap::drop` takes the entry out. `placed_heaps_start_at_the_title_memory` never released its placed heap, and its `Vec` was freed at the end of the test. That left a live registration over freed memory, which a later heap at the same address loses its writes to. Merged onto `67e8ae1` (no conflicts): the test passes, including the new reuse check. The full `victory-gpu` lib binary was run 50 times in parallel (Windows 10 19045, RTX 3080) with no `bindless::tests::heap_views_*` failure. To be fair to the numbers: I couldn't reproduce that flake on plain `main` on this machine either (0 in 300+ runs). So my support here rests on the deterministic reuse check and the code, not on a before/after rate.
upstream-sync closed this pull request 2026-11-25 22:03:36 +00:00
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
Marvisak/VIctory!2260
No description provided.