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

Merged
claytonblythe merged 1 commit from upstream-pr/23 into main 2026-11-26 09:36:40 +00:00
claytonblythe commented 2026-11-26 09:31:41 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by claytonblythe on 2026-11-26T09:31:41Z.


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.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6623644411 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/23). Originally posted by [claytonblythe](https://github.com/claytonblythe) on 2026-11-26T09:31:41Z. --- 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.
LakshanSivakumar commented 2026-11-26 09:36:37 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T09:36:37Z.

Review: APPROVED


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6071663913 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/23#pullrequestreview-6071663913). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T09:36:37Z. **Review:** APPROVED --- Tested: victory-gpu passes on x86_64 under Rosetta and on arm64. Thanks!
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
LakshanSivakumar/Native-Victory-macOS!23
No description provided.