gpu(tests): size native test pools for >=16 KiB pages under x86_64 Rosetta #23

Manually merged
github merged 1 commit from gh-pr/23/head into gh-pr/23/base 2026-11-26 14:42:46 +00:00
Owner

@⁠claytonblythe on GitHub · 2026-11-26 09:31 UTC · original
claytonblythe:fix/rosetta-gpu-test-pool-size → main · +6 −4 · 3 files · 1 commits · merged 2026-11-26 09:36 UTC

Closes #19.

Root Cause

This is a test-only issue (the real x86_64 game binary is unaffected):

  • The native Metal test helpers (Pool::new in tests.rs, pool() in title_tests.rs and texture_tests.rs) allocated pages * page_size() bytes and then wrote at fixed offsets 16384 (dst) and 32768 (done).
  • On native arm64, page_size() is 16 KiB, so 4 * page_size() == 64 KiB covers those offsets.
  • Under x86_64 Rosetta, sysconf(_SC_PAGESIZE) reports 4 KiB, so 4 * page_size() == 16 KiB, putting dst = 16384 and done = 32768 past the end of the mapping and triggering SIGSEGV / unmapped-pool failures.

Fix

  • Use page_size().max(16384) as the per-page unit in the test pool helpers (always a multiple of the host page size on both 4 KiB x86_64 and 16 KiB arm64).

Testing

  • VICTORY_MSC_DYLIB=... cargo test --target x86_64-apple-darwin -p victory-gpu --lib -- --test-threads=1: 140 passed, 0 failed (was 4 FAILED + SIGSEGV).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: 0 warnings.
  • cargo xtask policy: 363 files ok.
**@⁠claytonblythe** on GitHub · 2026-11-26 09:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/23) `claytonblythe:fix/rosetta-gpu-test-pool-size` → `main` · +6 −4 · 3 files · 1 commits · merged 2026-11-26 09:36 UTC Closes #19. ## Root Cause This is a **test-only** issue (the real x86_64 game binary is unaffected): - The native Metal test helpers (`Pool::new` in `tests.rs`, `pool()` in `title_tests.rs` and `texture_tests.rs`) allocated `pages * page_size()` bytes and then wrote at fixed offsets `16384` (`dst`) and `32768` (`done`). - On native `arm64`, `page_size()` is 16 KiB, so `4 * page_size() == 64 KiB` covers those offsets. - Under `x86_64` Rosetta, `sysconf(_SC_PAGESIZE)` reports 4 KiB, so `4 * page_size() == 16 KiB`, putting `dst = 16384` and `done = 32768` past the end of the mapping and triggering `SIGSEGV` / unmapped-pool failures. ## Fix - Use `page_size().max(16384)` as the per-page unit in the test pool helpers (always a multiple of the host page size on both 4 KiB x86_64 and 16 KiB arm64). ## Testing - `VICTORY_MSC_DYLIB=... cargo test --target x86_64-apple-darwin -p victory-gpu --lib -- --test-threads=1`: **140 passed, 0 failed** (was 4 FAILED + SIGSEGV). - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`: 0 warnings. - `cargo xtask policy`: 363 files ok.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:42:45 +00:00
github manually merged commit a592927a12 into gh-pr/23/base 2026-11-26 14:42:46 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 09:36 UTC · original · approved these changes

Tested: victory-gpu passes on x86_64 under Rosetta and on arm64. Thanks!

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 09:36 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/23#pullrequestreview-6071663913) · **approved these changes** Tested: victory-gpu passes on x86_64 under Rosetta and on arm64. Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.