runtime: establish contracts for the XMem default allocation pair #868

Closed
opened 2026-11-23 15:14:44 +00:00 by R0Y00 · 5 comments
R0Y00 commented 2026-11-23 15:14:44 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:14:44Z.


Refs #870, #126, #132.

The startup preflight found imports for XMemAllocDefault and XMemFreeDefault. The project's desktop xmem.dll already provides XMemAlloc and XMemFree. Establish the ABI and observable behavior of the default allocation pair, including ownership, size, alignment, allocation failure and the matching free operation.

Acceptance

  • Provide a public declaration or equivalent independently reproducible evidence for each interface.
  • Add a source-built x64 EXE that imports the pair by name. Compare normal Windows launch and pe_map, including successful allocation and forced failure with cleanup.
  • Record which semantics could be confirmed and identify the exact open question for any unresolved detail.

Available to claim. Comment with your environment and related work. Keep candidate binaries, dumps and private logs local.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6562433882 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/875). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T15:14:44Z. --- Refs #870, #126, #132. The startup preflight found imports for `XMemAllocDefault` and `XMemFreeDefault`. The project's desktop `xmem.dll` already provides `XMemAlloc` and `XMemFree`. Establish the ABI and observable behavior of the default allocation pair, including ownership, size, alignment, allocation failure and the matching free operation. **Acceptance** - Provide a public declaration or equivalent independently reproducible evidence for each interface. - Add a source-built x64 EXE that imports the pair by name. Compare normal Windows launch and `pe_map`, including successful allocation and forced failure with cleanup. - Record which semantics could be confirmed and identify the exact open question for any unresolved detail. Available to claim. Comment with your environment and related work. Keep candidate binaries, dumps and private logs local.
R0Y00 commented 2026-11-24 06:49:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:18:58Z.


The public SlimEra header at 912bb11 gives one ABI candidate: PVOID WINAPI XMemAllocDefault(SIZE_T, ULONGLONG) and void WINAPI XMemFreeDefault(PVOID, ULONGLONG). This is an independent reimplementation declaration. The target behavior for allocation failure, alignment and matching free still needs its own evidence.

For the source-built test, tests/cpu/shim_startup_check.py already checks named imports and compares native launch with pe_map. A small variant for this pair can reuse that setup. Please keep the ABI evidence and what the Windows shim actually does separate in the results, especially for failure and cleanup.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7105374055 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/875#issuecomment-7105374055). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T15:18:58Z. --- The public [SlimEra header at 912bb11](https://github.com/XWine1/SlimEra/blob/912bb1123e84f32023af6685989ac5d6747d767a/era.h) gives one ABI candidate: `PVOID WINAPI XMemAllocDefault(SIZE_T, ULONGLONG)` and `void WINAPI XMemFreeDefault(PVOID, ULONGLONG)`. This is an independent reimplementation declaration. The target behavior for allocation failure, alignment and matching free still needs its own evidence. For the source-built test, `tests/cpu/shim_startup_check.py` already checks named imports and compares native launch with `pe_map`. A small variant for this pair can reuse that setup. Please keep the ABI evidence and what the Windows shim actually does separate in the results, especially for failure and cleanup.
rasptum commented 2026-11-24 06:49:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T15:19:36Z.


Claiming this.

  • Milestone: #870 (first reproducible main-executable startup attempt), runtime/D3D12 bucket of #132.
  • Interface: desktop xmem.dll gains the named exports XMemAllocDefault(SIZE_T, ULONGLONG) -> PVOID and XMemFreeDefault(PVOID, ULONGLONG), matching the public declarations in SlimEra era.h and WinDurango kernelx.h. Both use the same era_heap policy as XMemAlloc/XMemFree.
  • Plan: a source-built x64 MASM EXE that imports the pair by name from xmem.dll. It runs under a normal Windows launch and under pe_map_run, and the two exit codes are compared: a heap block and a graphics block (alignment, zero fill, writes), a forced failure (reserved bit and zero size return null) with cleanup, and release checked by VirtualQuery. Negative controls: a variant that skips the free, a variant whose forced failure is unforced, and an unresolved-import diagnostic when the provider lacks the pair.
  • Environment: Windows 10 Pro 19045, MSVC x64, dev and release presets.
  • Overlap: no open PR touches src/xmem_shim*, src/era_heap* or pe_map. Hooks (XMemSetAllocationHooks) are out of scope.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7105390254 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/875#issuecomment-7105390254). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T15:19:36Z. --- Claiming this. - **Milestone:** #870 (first reproducible main-executable startup attempt), runtime/D3D12 bucket of #132. - **Interface:** desktop `xmem.dll` gains the named exports `XMemAllocDefault(SIZE_T, ULONGLONG) -> PVOID` and `XMemFreeDefault(PVOID, ULONGLONG)`, matching the public declarations in SlimEra `era.h` and WinDurango `kernelx.h`. Both use the same `era_heap` policy as `XMemAlloc`/`XMemFree`. - **Plan:** a source-built x64 MASM EXE that imports the pair by name from `xmem.dll`. It runs under a normal Windows launch and under `pe_map_run`, and the two exit codes are compared: a heap block and a graphics block (alignment, zero fill, writes), a forced failure (reserved bit and zero size return null) with cleanup, and release checked by `VirtualQuery`. Negative controls: a variant that skips the free, a variant whose forced failure is unforced, and an unresolved-import diagnostic when the provider lacks the pair. - **Environment:** Windows 10 Pro 19045, MSVC x64, `dev` and `release` presets. - **Overlap:** no open PR touches `src/xmem_shim*`, `src/era_heap*` or `pe_map`. Hooks (`XMemSetAllocationHooks`) are out of scope. AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:49:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:41:09Z.


Thanks for taking the native/mapped comparison. #879 now owns the desktop exports, so please build the fixture on that change and keep the follow-up to the test and evidence. Check that the EXE's PE import table contains both names and that the mapped resolver observes both names. VirtualQuery can confirm the graphics VA release. Use a separate ownership check for the heap block, where the containing heap region can stay committed after free. Please distinguish rejected inputs from any induced allocator failure.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7105950010 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/875#issuecomment-7105950010). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T15:41:09Z. --- Thanks for taking the native/mapped comparison. #879 now owns the desktop exports, so please build the fixture on that change and keep the follow-up to the test and evidence. Check that the EXE's PE import table contains both names and that the mapped resolver observes both names. `VirtualQuery` can confirm the graphics VA release. Use a separate ownership check for the heap block, where the containing heap region can stay committed after free. Please distinguish rejected inputs from any induced allocator failure.
rasptum commented 2026-11-24 06:49:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T16:58:13Z.


Result: #913. It changes only tests, CMake and docs, on top of #879.

Tested: commit 24f4297 on origin/main 02db28b. Windows 10 Pro 10.0.19045.6466, MSVC 19.44.35207.1 x64. Synthetic words only. cpu_native_xmem_default_pair starts each of four source-built EXEs under the Windows loader and under pe_map_run. The exits match in all four.

The checks you asked for:

  • pe_import_names: pefile finds xmem.dll!XMemAllocDefault and xmem.dll!XMemFreeDefault by name in every EXE.
  • mapped_resolver_names: the pe_map resolver callback is asked for both names, plus the five other imports, and nothing else. No pe_map.cpp change.
  • graphics_release_virtualquery: VirtualQuery reports the graphics VA as MEM_FREE after XMemFreeDefault.
  • heap_release_ownership: a separate ownership check, tests/cpu/heap_probe.cpp, locks and HeapWalks every process heap. Before free a busy entry contains the heap block; after free none does.
  • rejected_inputs vs induced_failure:
    • Rejected inputs (reserved bit 33, zero size, page size 3, memory type 15) return null and leave the last error at 0.
    • Induced failure uses valid words with 2^46 bytes. It returns null, and for the graphics word VirtualAlloc leaves a nonzero last error. A control allocation then succeeds.

Negative controls, all matching under both loaders:

  • skip_gpu_free gives 0xf14 (graphics release).
  • skip_heap_free gives 0xf15 (heap ownership).
  • uninduced gives 0xf0f (induced failure).
  • A provider missing either name stops the mapping before entry.

Results: dev and release each pass 20/20 (era_heap, era_physical, desktop_memory_query, the xmem_shim set and both XMem EXE pairs). The new test also passed 5/5 repeats in each preset. The form-coverage, docs-links and bidi checks pass.

Kept separate: the ABI candidate is SlimEra era.h at 912bb11, an independent reimplementation. The measured results describe only the Windows shim. The last-error split between rejected input and induced failure is observed desktop behavior. Console failure, alignment and release under hooks remain open.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7107951831 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/875#issuecomment-7107951831). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T16:58:13Z. --- Result: #913. It changes only tests, CMake and docs, on top of #879. **Tested:** commit `24f4297` on `origin/main` `02db28b`. Windows 10 Pro 10.0.19045.6466, MSVC 19.44.35207.1 x64. Synthetic words only. `cpu_native_xmem_default_pair` starts each of four source-built EXEs under the Windows loader and under `pe_map_run`. The exits match in all four. **The checks you asked for:** - **`pe_import_names`:** `pefile` finds `xmem.dll!XMemAllocDefault` and `xmem.dll!XMemFreeDefault` by name in every EXE. - **`mapped_resolver_names`:** the `pe_map` resolver callback is asked for both names, plus the five other imports, and nothing else. No `pe_map.cpp` change. - **`graphics_release_virtualquery`:** `VirtualQuery` reports the graphics VA as `MEM_FREE` after `XMemFreeDefault`. - **`heap_release_ownership`:** a separate ownership check, `tests/cpu/heap_probe.cpp`, locks and `HeapWalk`s every process heap. Before free a busy entry contains the heap block; after free none does. - **`rejected_inputs` vs `induced_failure`:** - Rejected inputs (reserved bit 33, zero size, page size 3, memory type 15) return null and leave the last error at 0. - Induced failure uses valid words with 2^46 bytes. It returns null, and for the graphics word `VirtualAlloc` leaves a nonzero last error. A control allocation then succeeds. **Negative controls**, all matching under both loaders: - `skip_gpu_free` gives `0xf14` (graphics release). - `skip_heap_free` gives `0xf15` (heap ownership). - `uninduced` gives `0xf0f` (induced failure). - A provider missing either name stops the mapping before entry. **Results:** dev and release each pass 20/20 (`era_heap`, `era_physical`, `desktop_memory_query`, the `xmem_shim` set and both XMem EXE pairs). The new test also passed 5/5 repeats in each preset. The form-coverage, docs-links and bidi checks pass. **Kept separate:** the ABI candidate is SlimEra `era.h` at 912bb11, an independent reimplementation. The measured results describe only the Windows shim. The last-error split between rejected input and induced failure is observed desktop behavior. Console failure, alignment and release under hooks remain open. AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:49:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:13:58Z.


Completed by #879 and #913. The named desktop exports and the source-built comparison are on main. Windows and pe_map both observe the expected names, successful heap/graphics allocation, input refusal versus induced allocation failure, and matching release. The graphics address is checked with VirtualQuery, and the heap block with a separate ownership probe. Each missing-export and release mutation was verified in Debug and Release. This records the tested desktop shim behavior. Console-specific allocation guarantees remain unverified.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7108349143 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/875#issuecomment-7108349143). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T17:13:58Z. --- Completed by #879 and #913. The named desktop exports and the source-built comparison are on main. Windows and pe_map both observe the expected names, successful heap/graphics allocation, input refusal versus induced allocation failure, and matching release. The graphics address is checked with VirtualQuery, and the heap block with a separate ownership probe. Each missing-export and release mutation was verified in Debug and Release. This records the tested desktop shim behavior. Console-specific allocation guarantees remain unverified.
Sign in to join this conversation.
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
R0Y00/Xbox2Windows#868
No description provided.