xmem tests: keep the chunked-span aperture inside one span chunk #659

Merged
snoozedDev merged 1 commit from upstream-pr/659 into main 2026-12-02 21:30:29 +00:00
snoozedDev commented 2026-12-02 19:25:32 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by snoozedDev on 2026-12-02T19:25:32Z.


Summary

Under GE-Proton11-14's Wine, tuxbox-xmem's unit tests fail about half the time with default test threads. At c1139ab2, with the test binary run from where cargo xwin test puts it, 14 of 30 runs failed. The same five tests fail every time:

  • chunked_private_span_shares_allocation_and_scans_across_uncommitted_gap: single chunked PrivateSpan covers all 3 sparse pages, left: 2, right: 1 (physical_tracking.rs:888)
  • held_pages_are_not_bridged_when_host_does_not_watch_held_pages, held_pages_keep_their_cpu_watch_where_the_host_allows_it, untracked_ranges_do_not_put_their_unheld_pages_on_the_scan_list and watched_pages_of_one_allocation_are_scanned_as_one_run_across_small_gaps then fail with PoisonError on POOL.lock().

Cause: the test reserves a 16-page aperture wherever the OS puts it, maps pages 0, 4 and 15, and expects one private span. Pool::private_span_bounds rounds spans to PRIVATE_SPAN_CHUNK (64 pages, 4 MiB) boundaries of the address, so an aperture that straddles a boundary gets two spans. That is what the provider is meant to do; the test's assumption is what fails. The assertion evaluates POOL.lock() inside assert_eq!, so it panics while holding the lock, which takes the four tracking tests down with it.

Where the aperture lands depends on the build and, under this Wine, on the length of the path the test binary runs from. In a local build with an eprintln! of the address (not part of this PR), I ran the binary from paths of different lengths. All 14 runs where the aperture straddled a 4 MiB boundary failed, and all 37 others passed (5 more runs interleaved their output and couldn't be read). From paths shorter than 56 characters it never straddled here. From most longer paths it often did, including cargo's own output path in this checkout.

The fix is in the test only: it sets aside any reservation that straddles a 64-page boundary, keeps the first one that doesn't, and releases the ones it set aside. No provider code changes.

Follows the test cleanup on #369. The Miri job on this PR stays red until #658 lands (two new tests reach VirtualAlloc2 without the Miri ignore); with both applied, CI's Miri line for xmem gives 0 failed; 50 ignored here (nightly 2026-11-29; CI pins nightly-2026-11-03).

This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review.

Tested

Run the checks relevant to this change.

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: neither. No GPU check was run: only a CPU-side unit test changes, so there is no GPU behaviour to check.

No Lanes scenario covers this because it changes a unit test only; nothing a game or Lanes runs changes. I didn't launch the game.

GPU, driver and backend: none (CPU-only).

The Evidence: line tuxbox.py check prints last, one per card (it names the commit it tested; run it on this pull request's head):

Evidence: TuxBox check of c768551b9556, no uncommitted changes, no GPU checks: 12 passed, 0 failed, 1 not run

(The one not run is the synthetic shaders through the runtime's DXC flags, which needs a Linux DXC that wasn't on PATH for this run.)

Commands run and their results:

cargo +1.95.0 xwin test --locked --no-run --target x86_64-pc-windows-msvc -p tuxbox-xmem
WINEPREFIX=<scratch> WINEDEBUG=-all WINEDLLOVERRIDES="mscoree,mshtml=d" \
  <GE-Proton11-14>/files/bin/wine <test exe>        # default test threads
where the binary ran from main (c1139ab2) failed this PR failed
cargo's output path in the checkout (141 characters) 14 of 30 0 of 30
a 128-character path 27 of 60 0 of 60, then 1 of 100
18 path lengths from 24 to 160 characters, 4 runs each 25 of 72 (0 of 16 below 56 characters) 0 of 72

Every failure on main includes the five tests above.

The one failure with this PR has a different cause and isn't fixed here. In that run physical_pages::backing::tests::gpu_pool_then_plain_cpu_view_upgrades_backing_and_keeps_mem_private failed first (physical_backing.rs:383, acquire_physical_backing on the second GPU alias returned 0, left: 0, right: 1) and left four spans in the pool, so this test then counted 5 spans and the same lock poisoning followed. I've seen that failure about once in 100 runs, on main too, and haven't traced it. One more run failed in an earlier 36-run sweep whose logs I didn't keep.

Also run:

  • cargo +1.95.0 clippy --locked --target x86_64-pc-windows-msvc --workspace --all-targets -- -D warnings and cargo fmt --all --check: pass.
  • On main with --test-threads=1, from the same 141-character path, 10 of 10 runs passed.

Checks

CI runs the code checks: the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU.

If this pull request changes evidence JSON, regenerate the results table and the progress map and include both files:

python tuxbox.py status > docs/RESULTS.md
python tuxbox.py status --svg docs/progress.svg

This pull request changes no evidence JSON.

<!-- greyfinch-sync:brcly/TuxBox:issue:5613209811 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/659). Originally posted by [snoozedDev](https://github.com/snoozedDev) on 2026-12-02T19:25:32Z. --- ## Summary Under GE-Proton11-14's Wine, `tuxbox-xmem`'s unit tests fail about half the time with default test threads. At c1139ab2, with the test binary run from where `cargo xwin test` puts it, 14 of 30 runs failed. The same five tests fail every time: - `chunked_private_span_shares_allocation_and_scans_across_uncommitted_gap`: `single chunked PrivateSpan covers all 3 sparse pages, left: 2, right: 1` (`physical_tracking.rs:888`) - `held_pages_are_not_bridged_when_host_does_not_watch_held_pages`, `held_pages_keep_their_cpu_watch_where_the_host_allows_it`, `untracked_ranges_do_not_put_their_unheld_pages_on_the_scan_list` and `watched_pages_of_one_allocation_are_scanned_as_one_run_across_small_gaps` then fail with `PoisonError` on `POOL.lock()`. Cause: the test reserves a 16-page aperture wherever the OS puts it, maps pages 0, 4 and 15, and expects one private span. `Pool::private_span_bounds` rounds spans to `PRIVATE_SPAN_CHUNK` (64 pages, 4 MiB) boundaries of the address, so an aperture that straddles a boundary gets two spans. That is what the provider is meant to do; the test's assumption is what fails. The assertion evaluates `POOL.lock()` inside `assert_eq!`, so it panics while holding the lock, which takes the four tracking tests down with it. Where the aperture lands depends on the build and, under this Wine, on the length of the path the test binary runs from. In a local build with an `eprintln!` of the address (not part of this PR), I ran the binary from paths of different lengths. All 14 runs where the aperture straddled a 4 MiB boundary failed, and all 37 others passed (5 more runs interleaved their output and couldn't be read). From paths shorter than 56 characters it never straddled here. From most longer paths it often did, including cargo's own output path in this checkout. The fix is in the test only: it sets aside any reservation that straddles a 64-page boundary, keeps the first one that doesn't, and releases the ones it set aside. No provider code changes. Follows the test cleanup on #369. The Miri job on this PR stays red until #658 lands (two new tests reach `VirtualAlloc2` without the Miri ignore); with both applied, CI's Miri line for xmem gives `0 failed; 50 ignored` here (nightly 2026-11-29; CI pins nightly-2026-11-03). This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review. ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: neither. No GPU check was run: only a CPU-side unit test changes, so there is no GPU behaviour to check. No Lanes scenario covers this because it changes a unit test only; nothing a game or Lanes runs changes. I didn't launch the game. GPU, driver and backend: none (CPU-only). The `Evidence:` line `tuxbox.py check` prints last, one per card (it names the commit it tested; run it on this pull request's head): ```text Evidence: TuxBox check of c768551b9556, no uncommitted changes, no GPU checks: 12 passed, 0 failed, 1 not run ``` (The one not run is the synthetic shaders through the runtime's DXC flags, which needs a Linux DXC that wasn't on `PATH` for this run.) Commands run and their results: ```text cargo +1.95.0 xwin test --locked --no-run --target x86_64-pc-windows-msvc -p tuxbox-xmem WINEPREFIX=<scratch> WINEDEBUG=-all WINEDLLOVERRIDES="mscoree,mshtml=d" \ <GE-Proton11-14>/files/bin/wine <test exe> # default test threads ``` | where the binary ran from | main (c1139ab2) failed | this PR failed | |---|---|---| | cargo's output path in the checkout (141 characters) | 14 of 30 | 0 of 30 | | a 128-character path | 27 of 60 | 0 of 60, then 1 of 100 | | 18 path lengths from 24 to 160 characters, 4 runs each | 25 of 72 (0 of 16 below 56 characters) | 0 of 72 | Every failure on main includes the five tests above. The one failure with this PR has a different cause and isn't fixed here. In that run `physical_pages::backing::tests::gpu_pool_then_plain_cpu_view_upgrades_backing_and_keeps_mem_private` failed first (`physical_backing.rs:383`, `acquire_physical_backing` on the second GPU alias returned 0, `left: 0, right: 1`) and left four spans in the pool, so this test then counted 5 spans and the same lock poisoning followed. I've seen that failure about once in 100 runs, on main too, and haven't traced it. One more run failed in an earlier 36-run sweep whose logs I didn't keep. Also run: - `cargo +1.95.0 clippy --locked --target x86_64-pc-windows-msvc --workspace --all-targets -- -D warnings` and `cargo fmt --all --check`: pass. - On main with `--test-threads=1`, from the same 141-character path, 10 of 10 runs passed. ## Checks CI runs the [code checks](../CONTRIBUTING.md#code-checks): the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU. If this pull request changes evidence JSON, regenerate the results table and the progress map and include both files: ```sh python tuxbox.py status > docs/RESULTS.md python tuxbox.py status --svg docs/progress.svg ``` This pull request changes no evidence JSON.
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
brcly/TuxBox!659
No description provided.