xgamesave: a blob read accepts the unpadded buffer size (RT-XGAMESAVE-UNPADDED-READ) #2359

Manually merged
github merged 1 commit from github-bot/gh-2359 into main 2026-11-26 16:30:28 +00:00 AGit
Owner

@⁠DadaCap on GitHub · 2026-11-26 15:22 UTC · original
DadaCap:xgamesave-unpadded-read → main · +30 −9 · 2 files · 1 commits · merged 2026-11-26 16:29 UTC

Claimed in the coordination issue as: #1608

Depends on: none. It merges cleanly with current main, #2003 and #1952 (both also touch the game-save files). It conflicts with draft #147, which already conflicts with main on its own.

What and why

XGameSaveReadBlobData (and the result of XGameSaveReadBlobDataAsync) packs the XGameSaveBlob array, then each blob's data and name into the title's buffer. A title sizes that buffer as the plain sum of sizeof(XGameSaveBlob), the data, and the name with its NUL for each blob. The shim required its own 8-byte aligned layout, which is larger, so it refused such a buffer with E_GS_PROVIDED_BUFFER_TOO_SMALL. The retail title took that refusal as a failed save and showed its autosave error.

The fix, in runtime/shims/xgameruntime_gamesave.cpp:

  • packed_size(blobs, aligned): the minimum the read requires, and the size the async read reports, is now the unpadded sum.
  • pack(blobs, buffer, buffer_size) keeps the 8-byte aligned layout when the buffer has room for it, and packs the blobs back to back otherwise. Callers that already passed a larger buffer get the same layout as before.

Tested

  • xgameruntime_gamesave_test gains two checks (made-up blobs, no game data): a read into a buffer of exactly the unpadded size succeeds and returns the blob byte for byte inside the buffer, and one byte less returns E_GS_PROVIDED_BUFFER_TOO_SMALL.
  • Before/after: with main's shim the new test fails (78 checks, 1 failures: the exact-size read is refused); with the change all checks pass (ctest -R ^xgameruntime_gamesave).
  • Built gta6rt (Windows 11, MSVC, Ninja, RelWithDebInfo). Not run: the full ctest suite and the translator suite (no shader or translator code changes).
  • python -I scripts/check_no_game_data.py on the changed files: clean.
  • Game observation, on a local build of main plus other local work: in the retail game on an RTX 5080 the read that failed now succeeds and the autosave error dialog no longer appears. No log lines or captures are quoted here.

GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (game observation only; the test needs no GPU).

AI-assisted: yes (Claude Code, Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr

**@⁠DadaCap** on GitHub · 2026-11-26 15:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2359) `DadaCap:xgamesave-unpadded-read` → `main` · +30 −9 · 2 files · 1 commits · merged 2026-11-26 16:29 UTC Claimed in the coordination issue as: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 Depends on: none. It merges cleanly with current `main`, #2003 and #1952 (both also touch the game-save files). It conflicts with draft #147, which already conflicts with `main` on its own. ### What and why `XGameSaveReadBlobData` (and the result of `XGameSaveReadBlobDataAsync`) packs the `XGameSaveBlob` array, then each blob's data and name into the title's buffer. A title sizes that buffer as the plain sum of `sizeof(XGameSaveBlob)`, the data, and the name with its NUL for each blob. The shim required its own 8-byte aligned layout, which is larger, so it refused such a buffer with `E_GS_PROVIDED_BUFFER_TOO_SMALL`. The retail title took that refusal as a failed save and showed its autosave error. The fix, in `runtime/shims/xgameruntime_gamesave.cpp`: - `packed_size(blobs, aligned)`: the minimum the read requires, and the size the async read reports, is now the unpadded sum. - `pack(blobs, buffer, buffer_size)` keeps the 8-byte aligned layout when the buffer has room for it, and packs the blobs back to back otherwise. Callers that already passed a larger buffer get the same layout as before. ### Tested - `xgameruntime_gamesave_test` gains two checks (made-up blobs, no game data): a read into a buffer of exactly the unpadded size succeeds and returns the blob byte for byte inside the buffer, and one byte less returns `E_GS_PROVIDED_BUFFER_TOO_SMALL`. - Before/after: with `main`'s shim the new test fails (`78 checks, 1 failures`: the exact-size read is refused); with the change all checks pass (`ctest -R ^xgameruntime_gamesave`). - Built `gta6rt` (Windows 11, MSVC, Ninja, RelWithDebInfo). Not run: the full ctest suite and the translator suite (no shader or translator code changes). - `python -I scripts/check_no_game_data.py` on the changed files: clean. - Game observation, on a local build of `main` plus other local work: in the retail game on an RTX 5080 the read that failed now succeeds and the autosave error dialog no longer appears. No log lines or captures are quoted here. GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (game observation only; the test needs no GPU). AI-assisted: yes (Claude Code, Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
A title sizes the read buffer as the sum of sizeof(XGameSaveBlob), the data and
the name with its NUL for each blob. The shim required the 8-byte aligned layout
and refused such a buffer with E_GS_PROVIDED_BUFFER_TOO_SMALL. The minimum (and
the async result size) is now the unpadded sum; the blobs are packed aligned
when the buffer has room for that and back to back otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:26:56 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 15:35 UTC · original · reviewed

Built xgameruntime_gamesave_test with MSVC on Windows 11. All 78 checks passed, including exact unpadded synchronous and asynchronous reads, preserved payloads, and rejection of a one-byte-short synchronous buffer. Synthetic save data only. No findings from these checks.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 15:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2359#pullrequestreview-6076849444) · **reviewed** Built `xgameruntime_gamesave_test` with MSVC on Windows 11. All 78 checks passed, including exact unpadded synchronous and asynchronous reads, preserved payloads, and rejection of a one-byte-short synchronous buffer. Synthetic save data only. No findings from these checks. AI-assisted.
github manually merged commit d5634defe4 into main 2026-11-26 16:30:28 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 16:29 UTC · original

Merging.

  • Why: the title sizes the XGameSaveReadBlobData buffer as the plain sum of its parts, and the shim demanded its 8-byte padded size and refused. That refusal is what the title's "couldn't autosave" dialog comes from. Blobs are now packed back to back when the padded layout does not fit; a larger buffer gets the same layout as before.
  • Tested on main 56bdd7e88 + this PR (be829a4d6):
    • The PR's test built against main's shim fails on the unpadded read, and xgameruntime_gamesave passes on the merge.
    • Windows suite under Wine (clang-cl + xwin, integrated RDNA2 GPU on RADV): 418 pass and 23 fail, against 417 and 24 on main. No test went from pass to fail. xmem_write_watch went from fail to pass, which this change does not touch.
    • test_ci_registration.py passes, and check_no_game_data.py is clean on both files.
  • Not tested: llvmpipe under Wine, and no game run, since the change is outside the rendering path.

Thanks @⁠DadaCap, and @⁠lixonik for the MSVC run.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

**@⁠aslan2142** on GitHub · 2026-11-26 16:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2359#issuecomment-7197708115) Merging. - **Why:** the title sizes the `XGameSaveReadBlobData` buffer as the plain sum of its parts, and the shim demanded its 8-byte padded size and refused. That refusal is what the title's "couldn't autosave" dialog comes from. Blobs are now packed back to back when the padded layout does not fit; a larger buffer gets the same layout as before. - **Tested on `main` `56bdd7e88` + this PR** (`be829a4d6`): - The PR's test built against `main`'s shim fails on the unpadded read, and `xgameruntime_gamesave` passes on the merge. - Windows suite under Wine (clang-cl + xwin, integrated RDNA2 GPU on RADV): 418 pass and 23 fail, against 417 and 24 on `main`. No test went from pass to fail. `xmem_write_watch` went from fail to pass, which this change does not touch. - `test_ci_registration.py` passes, and `check_no_game_data.py` is clean on both files. - **Not tested:** llvmpipe under Wine, and no game run, since the change is outside the rendering path. Thanks @⁠DadaCap, and @⁠lixonik for the MSVC run. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
This discussion has been locked. Commenting is limited to contributors.
No description provided.