Skip to content

Tests: guard unmapped placeholder read and release views in heap_probe - #1744

Open
kilvynsilveira-tech wants to merge 1 commit into
xcl-dev:mainfrom
kilvynsilveira-tech:tests/fix-heap-probe-cleanup-and-guards
Open

kilvynsilveira-tech wants to merge 1 commit into
xcl-dev:mainfrom
kilvynsilveira-tech:tests/fix-heap-probe-cleanup-and-guards

Conversation

@kilvynsilveira-tech

Copy link
Copy Markdown

Fix three bugs in crates/xcl/tests/heap_probe.rs and add a non-ignored CPU regression test for placeholder unmapping, coalescing, and release:

  1. In heaps_over_sections_in_a_placeholder, *((base + 11 * chunk) as *const u32) ran unconditionally after the loop even if chunk 1 skipped (MapViewOfFile3 or OpenExistingHeapFromFileMapping failure), dereferencing an unmapped PAGE_NOACCESS placeholder (0xc0000005). Guard the read on chunk 1 having mapped, assert its first word (1 << 28), and unmap + coalesce + VirtualFree the 256 MiB placeholder reservation on exit (and on early-continue error paths).
  2. In heaps_over_partly_committed_sections, failing CreatePlacedResource skipped UnmapViewOfFile(view) and CloseHandle(h), leaking up to 4 GiB of virtual address space and a file-mapping handle.
  3. In view_heap_capacity, return early when D3D12CreateDevice fails instead of panicking on .unwrap(), matching the other three probes in the file.

What is in it

  • crates/xcl/tests/heap_probe.rs:
    • Unmap view and close h on CreatePlacedResource failure in heaps_over_partly_committed_sections.
    • Guard null CreateFileMappingW, clean up views/handles on MapViewOfFile3 / OpenExistingHeapFromFileMapping failure, guard chunk 1's read on chunk1_mapped, and unmap (MEM_PRESERVE_PLACEHOLDER) + coalesce (MEM_COALESCE_PLACEHOLDERS) + release (VirtualFree(..., 0, MEM_RELEASE)) the placeholder reservation in heaps_over_sections_in_a_placeholder.
    • Return early on D3D12CreateDevice error in view_heap_capacity.
    • Add non-ignored test placeholder_chunks_unmap_coalesce_and_release_cleanly verifying that a skipped split chunk remains MEM_RESERVE / PAGE_NOACCESS and that UnmapViewOfFileEx + MEM_COALESCE_PLACEHOLDERS releases the full reservation.

Tested

  • Hardware / OS / Rust: AMD Radeon RX 580 2048SP (driver 31.0.21925.1001), AMD Ryzen 7 5700X 8-Core Processor, Windows 10 Home Single Language build 19045, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC dxcompiler 1.8.2502.11 (dxil 1.8.2502.11), debug build.
  • cargo test -p xcl --test heap_probe -- --nocapture on 91d7cda: 1 passed, 0 failed, 4 ignored.
  • cargo test -p xcl --test heap_probe -- --ignored --nocapture on 91d7cda (RX 580): 4 passed, 0 failed, 0 ignored (all four D3D12 probes ran and released their views, handles, and 256 MiB placeholder reservation cleanly).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 91d7cda: 858 passed, 1 failed, 42 ignored (242 SKIPPED SM 6.6 GPU tests on RX 580; the 1 failure is pre-existing on main in gpu_raw_window_view_reaches_its_top, addressed separately in Tests: skip gpu_raw_window_view_reaches_its_top without SM 6.6 #1736).

Regression run

  • Not needed: test-only changes in crates/xcl/tests/heap_probe.rs.

Not tested

  • Headless host without any D3D12 adapter (D3D12CreateDevice succeeds on RX 580).
  • Retail Xbox Series X|S titles.

AI use

  • Antigravity (Gemini 4 Carbon): found the bugs in heap_probe.rs, wrote the fix, regression test, and PR description, and ran the test suites on RX 580 under the user's direction.

In heaps_over_sections_in_a_placeholder, skipping chunk 1 left its placeholder PAGE_NOACCESS while the post-loop read still dereferenced it, and neither the mapped chunk views nor the 256 MiB reservation were released. Also unmap/close on CreatePlacedResource failure in heaps_over_partly_committed_sections, return cleanly on D3D12CreateDevice failure in view_heap_capacity, and add a non-ignored CPU test for placeholder split/unmap/coalesce/release.

Assisted-by: Antigravity (Gemini 4 Carbon)
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 91d7cda (on its base 9039900).

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, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 858 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: placeholder_chunks_unmap_coalesce_and_release_cleanly.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 859 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set XCL_REQUIRE_GPU, so there both just print SKIPPED.

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.

@ivall ivall added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 24, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 28, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 91d7cda

No open or merged PR makes the same change; #1328 adds separate probes to heap_probe.rs and does not touch these lines.
The guard in heaps_over_sections_in_a_placeholder (read chunk 1's first word only when it was mapped) and the view/placeholder cleanup are correct.
placeholder_chunks_unmap_coalesce_and_release_cleanly is not #[ignore], so it runs in CI, and it checks the Windows placeholder APIs on their own rather than the guarded probe code. The early return in view_heap_capacity is an unrelated change.
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

off-goal Does not bear on the current goal (world loading); waits until it is reached stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants