Skip to content

Memory: size executable arenas for the requested allocation - #1155

Open
anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:memory/size-executable-arenas
Open

anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:memory/size-executable-arenas

Conversation

@anakatt

@anakatt anakatt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

I make alloc_code honor requests larger than its default 64 KiB arena. Previously, it committed only 64 KiB and advanced the allocation cursor by the larger requested size, returning a pointer without enough backing memory.

What is in it

  • stubs.rs: size each new arena for the aligned request, reject alignment overflow before locking, and compare against remaining capacity without overflowing an address addition.
  • VirtualQuery regression for large requests and a subsequent small request; overflow regression and allocation-contract documentation.

This is independent of #936's unwind registration; it does not add unwind metadata.

Tested

I ran debug tests on Windows 11 Pro ARM64 10.0.26100.1742 in UTM (4 GiB RAM, virtual virt-10.0 CPU, Red Hat VirtIO GPU DOD), with Rust 1.100.0 x86_64-pc-windows-msvc and Visual Studio 2022 Build Tools. The guest used main 47efa2ecea0a12934719ae69b81930cf02a4b1c3 plus the source changes committed as a59c84e8309560e5dbf90e17ae965ee6d0c82212.

  • Before the fix, cargo test --locked -p xcl --lib stubs::tests::executable_allocations_cover_the_requested_size -- --exact: 0 passed, 1 failed, 0 ignored, 720 filtered out. VirtualQuery showed 65,537 requested bytes backed by only 65,536 committed bytes; the test did not write past the allocation.
  • After the fix, cargo test --locked -p xcl --lib stubs::tests -- --test-threads=4: 5 passed, 0 failed, 0 ignored, 716 filtered out; no SKIPPED output. This includes the allocation regressions, generated stub execution and concurrent stub reuse.

Not tested

I have not run the release profile, full workspace suite, native x64 Windows hardware, D3D12 GPU execution or a real title. I have not observed a game requesting an executable allocation larger than 64 KiB; this reproduces the allocator contract failure directly.

Regression run

Not run. This remains a draft pending the required real-title xcl-smoke blocks from main and this PR's clean head, with the same title and duration.

AI use

I used omp (openai-codex/gpt-6-astra) to investigate, implement the fix and regressions, run the Windows tests, and prepare this PR.

alloc_code always committed a 64 KiB arena, even when the aligned request
was larger. Its returned pointer therefore did not cover the requested
range, and the bump cursor advanced past the arena end.

Allocate the larger of the default arena and the aligned request. Reject
alignment overflow before taking the arena mutex, and compare the request
against remaining capacity without adding it to an address.

Windows 11 ARM64 VM, x64 MSVC rustc 1.100.0: VirtualQuery reproduced
65537 requested bytes backed by only 65536 committed bytes before the fix.
Afterward cargo test --locked -p xcl --lib stubs::tests -- --test-threads=4
passed 5 tests, 0 failed, 0 ignored (716 filtered out), including overflow
rejection, generated-code execution and concurrent stub reuse.
No real-title smoke run or release-profile test was performed.

Assisted-by: omp (openai-codex/gpt-6-astra)
@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.

  • cargo test -p xcl --lib stubs: 7 passed, 0 failed.
  • cargo test -p xcl --lib arena: 5 passed, 0 failed, 1 ignored — gpu_unified_memory_arena and arena_blocks_come_from_the_pool_when_the_title_took_the_rest exercise the sized-arena path on the real backend.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit a59c84e

Verified clean merge with main (47efa2e) on a59c84e8309560e5dbf90e17ae965ee6d0c82212: pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 743 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none), including stubs::tests::executable_allocations_cover_the_requested_size and stubs::tests::executable_allocation_rejects_size_overflow

Regression run
main (47efa2e):

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14853 MB

PR (a59c84e):

xcl-smoke v1
commit: a59c84e8309560e5dbf90e17ae965ee6d0c82212
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14855 MB

Not tested

  • retail paths requesting single executable stub thunks larger than 64 KB (ARENA_CHUNK); gameplay past the menus

AI use: Antigravity (Google DeepMind), Gemini (exact version string not exposed in runtime environment) — ran the workspace test suite and 60 s retail smoke check on the hardware above and formatted this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants