fix(libSceSaveData.native): answer sceSaveDataCancel before initialization as measured in a PS5 payload #11720

Merged
ionut27001 merged 1 commit from upstream-pr/11720 into main 2026-10-29 11:57:25 +00:00
ionut27001 commented 2026-10-27 05:28:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ionut27001 on 2026-10-27T05:28:43Z.


What

sceSaveDataCancel threw for every call. Marvel's Wolverine (PPSA03671) imports it from libSceSaveData.native.

In a payload process on a PS5 (firmware 12.70), sceSaveDataCancel from /system/common/lib/libSceSaveData.native.sprx returned 0x809f0001 (SAVE_DATA_ERROR_NOT_INITIALIZED) for the arguments 0, 1, 2 and 0xffffffff before the library was initialized. In an earlier payload run on the same console, libSceSaveData.sprx loaded but did not resolve sceSaveDataCancel by name.

This change returns SAVE_DATA_ERROR_NOT_INITIALIZED while the library is not initialized, using the same g_initializations check as the other save-data calls. Once the library is initialized, the call still throws. In the same payload process, sceSaveDataInitialize3(NULL) never returned a result, so the initialized case was not measured. The debt entry records that gap.

Measured log (case lines, payload process, firmware 12.70):

case load path=/system/common/lib/libSceSaveData.native.sprx ret_ok=1 ret=0x21 start_result=0
case resolve module=libSceSaveData.native.sprx sceSaveDataCancel found=1
case resolve sceSaveDataInitialize3 found=1 sceSaveDataTerminate found=1
case cancel phase=before_init arg=0 ret=0x809f0001
case cancel phase=before_init arg=0x1 ret=0x809f0001
case cancel phase=before_init arg=0x2 ret=0x809f0001
case cancel phase=before_init arg=0xffffffff ret=0x809f0001

The next call, sceSaveDataInitialize3(NULL), produced no further output before the runner's 60-second timeout, so it either hung or ended the process.

Overlaps: no open PR changes sceSaveDataCancel. #11697, #11080, #11083, #8285, #8630 and #7780 edit the same files elsewhere.

Tested

Windows 11, WinLibs GCC 15.2.0, Release, on main 9cc1a379c0:

  • With this change: guest_savedata_cancel passes twice. It checks the four measured arguments before initialization, that the call still throws after sceSaveDataInitialize3, and that it reports not initialized again after sceSaveDataTerminate.
  • Revert check: with Export.cpp from main, the test aborts (0xc0000409), because the call throws before initialization.

Not tested on Linux, nor with a title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5029077215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11720). Originally posted by [ionut27001](https://github.com/ionut27001) on 2026-10-27T05:28:43Z. --- ### What `sceSaveDataCancel` threw for every call. Marvel's Wolverine (PPSA03671) imports it from `libSceSaveData.native`. In a payload process on a PS5 (firmware 12.70), `sceSaveDataCancel` from `/system/common/lib/libSceSaveData.native.sprx` returned `0x809f0001` (`SAVE_DATA_ERROR_NOT_INITIALIZED`) for the arguments 0, 1, 2 and 0xffffffff before the library was initialized. In an earlier payload run on the same console, `libSceSaveData.sprx` loaded but did not resolve `sceSaveDataCancel` by name. This change returns `SAVE_DATA_ERROR_NOT_INITIALIZED` while the library is not initialized, using the same `g_initializations` check as the other save-data calls. Once the library is initialized, the call still throws. In the same payload process, `sceSaveDataInitialize3(NULL)` never returned a result, so the initialized case was not measured. The debt entry records that gap. Measured log (case lines, payload process, firmware 12.70): ``` case load path=/system/common/lib/libSceSaveData.native.sprx ret_ok=1 ret=0x21 start_result=0 case resolve module=libSceSaveData.native.sprx sceSaveDataCancel found=1 case resolve sceSaveDataInitialize3 found=1 sceSaveDataTerminate found=1 case cancel phase=before_init arg=0 ret=0x809f0001 case cancel phase=before_init arg=0x1 ret=0x809f0001 case cancel phase=before_init arg=0x2 ret=0x809f0001 case cancel phase=before_init arg=0xffffffff ret=0x809f0001 ``` The next call, `sceSaveDataInitialize3(NULL)`, produced no further output before the runner's 60-second timeout, so it either hung or ended the process. Overlaps: no open PR changes `sceSaveDataCancel`. #11697, #11080, #11083, #8285, #8630 and #7780 edit the same files elsewhere. ### Tested Windows 11, WinLibs GCC 15.2.0, Release, on `main` 9cc1a379c0: - **With this change:** `guest_savedata_cancel` passes twice. It checks the four measured arguments before initialization, that the call still throws after `sceSaveDataInitialize3`, and that it reports not initialized again after `sceSaveDataTerminate`. - **Revert check:** with `Export.cpp` from `main`, the test aborts (0xc0000409), because the call throws before initialization. Not tested on Linux, nor with a title. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-27 05:35:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T05:35:06Z.

Review: APPROVED


Reviewed the exact current head 410e7c4c18cb51d174f53317d7834a13dd662cd6, the focused implementation/test/debt update, and the current-main merge preview. The g_initializations check is consistent with the measured pre-initialization results for all four arguments, and the test covers the uninitialized → initialized/still-unimplemented → terminated lifecycle. The debt entry accurately records the unknown initialized console behavior. git diff --check passes and the merge preview is clean.

I did not rerun the Windows test locally; the PR reports two passing runs plus a revert control, and current hosted product build jobs are skipped by path policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5662672119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11720#pullrequestreview-5662672119). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T05:35:06Z. **Review:** APPROVED --- Reviewed the exact current head `410e7c4c18cb51d174f53317d7834a13dd662cd6`, the focused implementation/test/debt update, and the current-main merge preview. The `g_initializations` check is consistent with the measured pre-initialization results for all four arguments, and the test covers the uninitialized → initialized/still-unimplemented → terminated lifecycle. The debt entry accurately records the unknown initialized console behavior. `git diff --check` passes and the merge preview is clean. I did not rerun the Windows test locally; the PR reports two passing runs plus a revert control, and current hosted product build jobs are skipped by path policy.
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
boykopovar/AnyPS5!11720
No description provided.