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

Open
github-bot wants to merge 1 commit from github-bot/gh-1744 into main AGit
Owner

@⁠kilvynsilveira-tech on GitHub · 2026-11-24 20:08 UTC · original
kilvynsilveira-tech:tests/fix-heap-probe-cleanup-and-guards → main · +67 −4 · 1 files · 1 commits · open

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 #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.
**@⁠kilvynsilveira-tech** on GitHub · 2026-11-24 20:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1744) `kilvynsilveira-tech:tests/fix-heap-probe-cleanup-and-guards` → `main` · +67 −4 · 1 files · 1 commits · open 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 #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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:03:26 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 21:17 UTC · original · edited 2026-11-24 21:39 UTC

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 (#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.
**@⁠futurepro62** on GitHub · 2026-11-24 21:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/1744#issuecomment-7144725180) · edited 2026-11-24 21:39 UTC 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 (#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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 22:55 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-24 22:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1744#issuecomment-7146804739) 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!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1744/head:github-bot/gh-1744'
git switch 'github-bot/gh-1744'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1744'
git switch 'github-bot/gh-1744'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1744'
git switch 'github-bot/gh-1744'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1744'
git switch 'main'
git merge --squash 'github-bot/gh-1744'
git switch 'main'
git merge --ff-only 'github-bot/gh-1744'
git switch 'main'
git merge 'github-bot/gh-1744'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.