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

Merged
DadaCap merged 1 commit from upstream-pr/2359 into main 2026-11-26 16:29:15 +00:00
DadaCap commented 2026-11-26 15:22:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-26T15:22:18Z.


Claimed in the coordination issue as: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7196167761

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5512704074 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2359). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-26T15:22:18Z. --- Claimed in the coordination issue as: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7196167761 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
lixonik commented 2026-11-26 15:35:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:35:03Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6076849444 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2359#pullrequestreview-6076849444). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T15:35:03Z. **Review:** COMMENTED --- 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.
aslan2142 commented 2026-11-26 16:29:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-26T16:29:12Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7197708115 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2359#issuecomment-7197708115). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-26T16:29:12Z. --- 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)
Sign in to join this conversation.
No reviewers
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
ProjectLeonida/mandy!2359
No description provided.