Skip to content

Exercise the EXE startup allocation sequence through gta6rt --run (RT-496) - #6944

Draft
ligmaSec wants to merge 1 commit into
ItsNotRexed:mainfrom
ligmaSec:test/exe-startup-xmem-reservations
Draft

ligmaSec wants to merge 1 commit into
ItsNotRexed:mainfrom
ligmaSec:test/exe-startup-xmem-reservations

Conversation

@ligmaSec

Copy link
Copy Markdown
Contributor

RT-496 covers the RT-5 EXE boot path. It runs a hand-written x64 PE through gta6rt --run and calls XMemVirtualAlloc through the guest's xmem.dll import. This lets contributors check the startup allocation sequence without the retail EXE, GPU, or game-sized memory reservations. Coordination claim.

Depends on: #6878

Depends on: #4531

The guest makes two reserve-only requests with 64 KiB alignment and three reserve-and-commit requests with 2 MiB alignment. It keeps them live together, queries the base address, rounded size, state and protection, writes and reads both ends of each committed region, then frees the regions in reverse order. The CTest requires both the guest's success message and the loader's zero exit report. The link stub returns null, so resolving that stub cannot accidentally pass the test.

Verification

Built the PE and runtime with clang-cl 21.1.8, MSVC 14.44 libraries and Windows SDK 10.0.26100 on Linux. Ran the mapped guest on CPU with Wine. No retail EXE or physical GPU was used.

Runtime tested Result
Main at 1cc6e3c1, Wine 11 First 64 KiB reservation fails with Win32 error 50
Main plus #6878, Wine 11 Both reservations succeed, then the first 2 MiB commitment fails with error 50
Main plus #6878 and #4531, Wine 11 All five pass with the default allocator and with LEONIDA_XMEM_NO_VIRTUALALLOC2=1
Same combined build, Wine 10 All five pass and the loader reports exit code 0

The two implementation branches overlap in the allocator. For the combined test I resolved that conflict locally by retaining #6878's normalization before calling #4531's aligned allocation path. This draft contains only the fixture, its link stub export and CMake registration. The combined result applies to that local resolution. The draft can be rerun after those implementations land.

ctest --test-dir runtime/build -C RelWithDebInfo -R '^run_tiny_xmem_startup$' --output-on-failure

The CTest registration suite also passed (4 tests), as did the repository's game-data check. AI-assisted contribution.

ASTROWwwW pushed a commit to ASTROWwwW/Leonida that referenced this pull request Nov 23, 2026
…on sequence through gta6rt --run (RT-496)

Author: ligmaSec

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UkEUa9YfGQH4p9g1Guw9gq
@cynbun

cynbun commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 2639b29ab on Linux, RTX 5080 (Blackwell), NVIDIA 615.78.08, Python 3.14.8: fail (as the PR expects without its dependencies) — run_tiny_xmem_startup does not pass on current main with any dependency that merges cleanly.

Setup: Windows cross-build (clang-cl 23.1.3 + xwin SDK 10.0.26100, runtime/cmake/clang-cl-xwin.cmake, RelWithDebInfo), tests under Wine 11.20, fresh prefix. Dependency state: #6878 is closed (duplicate), #4531 (fc1f8dd8f) and #6709 conflict with main in runtime/shims/xmem.cpp / runtime/test/xmem_test.cpp, so I did not resolve them. #6919 (36936f3bf, also serves 2 MiB pages and placeholders in XMemVirtualAlloc) merges cleanly, so I tried that instead.

cmake -S runtime -B <build> -G Ninja --toolchain runtime/cmake/clang-cl-xwin.cmake -DXWIN_DIR=<xwin>
cmake --build <build>
ctest --test-dir <build> -j1 --timeout 300 -R '^run_tiny_xmem_startup$' -V
Tree run_tiny_xmem_startup
main e6190e7b5 + this PR FAIL 0x183 commitment allocation (Win32 error 50): the two 64 KiB reservations now succeed on main; the first 2 MiB commitment is refused
main e6190e7b5 + this PR + #6919 all five allocations succeed, the four other region checks pass, but FAIL CPU reservation query (size 131072, state 0x2000, protection 0x1/0)

Same results with LEONIDA_XMEM_NO_VIRTUALALLOC2=1. The #6919 mismatch comes from its design: a reserve-only 64 KiB-page region becomes a placeholder window, whose host AllocationProtect is PAGE_NOACCESS (the requested protection is recorded by the shim and applied to mapped pages). This fixture expects AllocationProtect == PAGE_READWRITE for the CPU reservation. If #6919 lands first, either the fixture or that PR needs to agree on what a reserve-only region reports.

The negative control is the first row: the fixture fails on main as it is, and the stub XMemVirtualAlloc returns null, so the pass depends on the shim.

Other tests (main + this PR): xmem passes, and the 23 tests matching run_|loader|xmem|bundled give 21 pass, 2 fail. The failures are run_tiny_xmem_startup (above) and run_tiny_game_abort_exit_codes (FAIL native abort-default: exit code 3, expected 3221226505). The second also fails on main 77247b699 under the same Wine, so this PR does not cause it.

Not tested: the full combination with #4531 that the PR description reports passing (it would need a manual conflict resolution), and native Windows.

AI-assisted (Claude Code).

cc @shayderrr

@umnitus

umnitus commented Nov 23, 2026

Copy link
Copy Markdown

Independent native Windows check at 2639b29ab33ce051a298f0b9082ebb8ce69484d0 with clang-cl/xwin. The stock run_tiny_xmem_startup test stopped at the first CPU reservation with Win32 error 50.

With a local integration of #6878 at 9e6ff05f and #4531 at fc1f8dd8, all five allocations passed and the guest exited 0 with both the default allocator and LEONIDA_XMEM_NO_VIRTUALALLOC2=1. The local merge retained #6878's protection normalization before #4531's aligned allocation path. AI-assisted testing.

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