runtime: handle save staging allocation failure #2697

Manually merged
github merged 3 commits from gh-pr/2697/head into gh-pr/2697/base 2026-11-27 01:15:46 +00:00
Owner

@⁠louisdibiasi on GitHub · 2026-11-26 02:23 UTC · original
louisdibiasi:louis/gamesave-stage-oom → main · +55 −15 · 3 files · 3 commits · merged 2026-11-26 02:50 UTC

Change

When the staged-action vector cannot allocate, save slot 25 or 26 currently lets std::bad_alloc escape while holding the save lock. The update also charges the action's bytes before the action is kept. Return the existing out-of-memory result instead, and charge the bytes only after insertion succeeds. A later action can then be staged and submitted.

The source-built submit fixture injects the vector allocation failure, checks the error, and retries a write through the ordinary dispatcher. Restoring the old staging code makes the controlled test fail. This covers that allocation point; it does not claim that a startup run encountered it or cover allocations earlier in the call.

Verification

Windows x64, MSVC 19.44, commit bc37c682 (base e76f8acd):

  • cmake --build --preset dev --target startup_gamesave_submit and ctest --preset dev --no-tests=error -R '^startup_gamesave_submit_' --output-on-failure: 2 passed.
  • cmake --build --preset release --target startup_gamesave_submit and the same CTest filter with --preset release: 2 passed.
  • With the original stage behavior temporarily restored, the controlled test failed (CTest exit 8); the patch was restored afterward.
  • On base 686915ea before the unrelated upstream fast-forward, cmake --build --preset pr and ctest --preset pr --no-tests=error: 34 passed, 4 MinLOD capability skips. The submit checks were rerun on the final base.

AI-assisted (Codex). Synthetic fixture only; no title data or application run.

**@⁠louisdibiasi** on GitHub · 2026-11-26 02:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2697) `louisdibiasi:louis/gamesave-stage-oom` → `main` · +55 −15 · 3 files · 3 commits · merged 2026-11-26 02:50 UTC ## Change When the staged-action vector cannot allocate, save slot 25 or 26 currently lets `std::bad_alloc` escape while holding the save lock. The update also charges the action's bytes before the action is kept. Return the existing out-of-memory result instead, and charge the bytes only after insertion succeeds. A later action can then be staged and submitted. The source-built submit fixture injects the vector allocation failure, checks the error, and retries a write through the ordinary dispatcher. Restoring the old staging code makes the controlled test fail. This covers that allocation point; it does not claim that a startup run encountered it or cover allocations earlier in the call. ## Verification Windows x64, MSVC 19.44, commit bc37c682 (base e76f8acd): - `cmake --build --preset dev --target startup_gamesave_submit` and `ctest --preset dev --no-tests=error -R '^startup_gamesave_submit_' --output-on-failure`: 2 passed. - `cmake --build --preset release --target startup_gamesave_submit` and the same CTest filter with `--preset release`: 2 passed. - With the original stage behavior temporarily restored, the controlled test failed (CTest exit 8); the patch was restored afterward. - On base 686915ea before the unrelated upstream fast-forward, `cmake --build --preset pr` and `ctest --preset pr --no-tests=error`: 34 passed, 4 MinLOD capability skips. The submit checks were rerun on the final base. AI-assisted (Codex). Synthetic fixture only; no title data or application run.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:15:43 +00:00
github manually merged commit 53fe958b89 into gh-pr/2697/base 2026-11-27 01:15:46 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-26 02:45 UTC · original

Extended the staging fix to catch allocation failure while making the private copy of the blob, before the update holds its lock. Tested 53fe958b with MSVC Debug and /O2, both the synthetic scheduler and the Windows system Immediate queue (4/4). The fixture injects separately at the action-list append and the blob copy, then retries the same update. With the pre-fix preparation code the new control exits 20 when bad_alloc escapes.

**@⁠R0Y00** on GitHub · 2026-11-26 02:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2697#issuecomment-7181098389) Extended the staging fix to catch allocation failure while making the private copy of the blob, before the update holds its lock. Tested 53fe958b with MSVC Debug and /O2, both the synthetic scheduler and the Windows system Immediate queue (4/4). The fixture injects separately at the action-list append and the blob copy, then retries the same update. With the pre-fix preparation code the new control exits 20 when bad_alloc escapes.
This discussion has been locked. Commenting is limited to contributors.
No description provided.