runtime: check Windows commit budget before mapped EXE startup #1474
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1481"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-24T12:42:25Z.
Summary
Add an optional Windows system commit-headroom preflight to
tools/pe_run_package.py, before it parses a package, loads shim DLLs, maps an EXE or enters guest code.On Windows a large source-built package can fail at startup because the system commit limit (RAM + paging-file backing) is exhausted even when free physical RAM exists. A documented example is Windows error 1455 in VIctory's public README at
ffe310e. This PR does not copy or adapt VIctory's GPL code: it uses the public MicrosoftGetPerformanceInfoAPI and a separately authored, read-only implementation.--min-commit-mib N: readCommitLimitandCommitTotalfrom systempsapi.dll, multiply byPageSize, and refuse when headroom is below the caller's chosen threshold. No guessed default is imposed.--min-commit-mib 0: report current commit figures without imposing a threshold. If present, both execution and--preflight-onlyJSON add ahost_commitobject. Without the flag the existing behavior and JSON shape stay unchanged.psapi.dllfrom System32 only (LOAD_LIBRARY_SEARCH_SYSTEM32) to avoid local DLL planting. Counts are converted in Python integers; a counter over the limit floors headroom to zero instead of wrapping; zero page sizes/limits are rejected; the operating-system error surfaces if the call fails.Usage
Verification
Locally on Linux:
Observed: 6/6 new portable tests passed, the 7th (live Windows API smoke) skipped on Linux by design; 3/3 ordinal-planning and 13/13 existing preflight tests passed; dependency/path/routing, docs (16 files/334 links) and bidi (1,217 tracked files) checks passed. The native Windows smoke is registered in CTest and will run on CI; no native Windows success is claimed yet.
The tests cover exact-budget and one-MiB-short thresholds, total >= limit, fractional MiB, invalid counters/requirements, correct 32-bit DWORD / pointer-sized
SIZE_TAPI structure, call errors, preflight rejection beforeinspect()/run(), and opt-in vs unchanged JSON output. No game files or actual allocations are used.Limits
This addresses an observable host resource precondition, not title-specific requirements, console memory contracts, render pipeline behavior or GTA VI playability. Actual commit demand is unknown and can fluctuate; a passing snapshot is never a guarantee. No binary/data from VIctory or a title is included. MIT-compatible original code only.
AI-assisted. Commit
0400187a.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:57:38Z.
Review: COMMENTED
Reviewed at commit
0400187aa71257e5d9953779af8aceef789a74b9:Code & Diff Audit
tools/host_commit.py:PerformanceInformationmatches WindowsPERFORMANCE_INFORMATIONlayout (DWORD cb, 10SIZE_Tfields, 3DWORDcounts), loadspsapi.dllwithwinmode=0x800(LOAD_LIBRARY_SEARCH_SYSTEM32), guards against zeroPageSize/CommitLimitandCommitTotal > CommitLimitunderflow, and checks--min-commit-mibbefore package resolution,inspect(), orrun(). (Minor nit:isinstance(minimum_mib, int)inrequire_commit_budget()acceptsboolif called directly as a library function, thoughargparsetype=intprevents that on the CLI.)tests/host_commit_check.py:80):HostCommitChecks.test_winapi_failure_and_unsupported_hostcallsread_host_commit()without patchinghost_commit.sys.platformto a non-Windows platform. On Windows (sys.platform == "win32"),read_host_commit()callsGetPerformanceInfoand succeeds instead of raisingOSError, causingpe_host_commit_preflightto fail on Windows. Wrapping that assertion inwith patch("host_commit.sys.platform", "linux"):will fix it.Verification
tests/docs_links_check.py(16 files, 334 links),tests/bidi_controls_check.py(1,219 files), andgit diff --check origin/main..HEADpassed; clean merge withorigin/main.--preset dev):pe_package_import_closurepassed (0.41s),pe_host_commit_preflightFAILED (0.29s) intest_winapi_failure_and_unsupported_host(AssertionError: OSError not raisedattests/host_commit_check.py:80). Release was not run after the Debug CTest failure.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T12:58:43Z.
Maintainer update at
c0ade401makes the unsupported-host assertion independent of the test runner OS. On Windows all seven checks passed, including the real System32 GetPerformanceInfo smoke. The real CLI also rejected an excessive budget before resolving the deliberately missing package. Ordinal and preflight checks passed (16/16), as did dependency paths and Markdown links.