fix(libSceSharePlay): accept a null heap in sceSharePlayInitialize #2946

Merged
SleglJan merged 1 commit from upstream-pr/2946 into main 2026-10-10 20:13:01 +00:00
SleglJan commented 2026-10-10 18:46:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T18:46:17Z.


What

sceSharePlayInitialize threw on a null heap. PPSA11386 (007 First Light) calls sceSharePlayInitialize(NULL, 0x1800) at start-up. On any non-zero result it logs sceSharePlayInitialize() failed (0x%x) and executes int 0x42. That is read at the call site in the relinked executable: mov esi, 0x1800; xor edi, edi; call; test eax, eax; je past the log and the trap. So the console accepts a null heap with a non-zero size. This implementation keeps no state and does not use the heap. A zero size still throws, because its error code is unknown. The null and zero checks came with #153. Recorded in TechnicalDebt.

libSceSharePlay gets its own CMakeLists.txt for the test, modelled on libSceShare's. It links libc and calls configure_windows_unwind, because the test checks a throw.

This is 007's next stop on main 1476f769, row 2 of #2523. Row 1 was #2830 and #2831, both now merged. Row 3 (#1921) is already passed on main by #1964, so with this change the title stops next on row 4.

Overlap: no open pull request changes libSceSharePlay.

Tested

  • Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), Ryzen 9 7950X3D, RTX 3080 (NVIDIA 615.71.09), Release with BUILD_TESTING=ON and ANYPS5_ENABLE_SPIRV_TOOLS=ON, this branch on main 1476f769. Of 705 tests, 700 pass, four video_out_flip_* tests (lifetime, reopen, controls, overlay) skip (no Vulkan in SDL's offscreen video driver), and agc_driver_dcc_keys_first_write fails, which is #2767 (NVIDIA, Linux).

  • The new guest_share_play test covers three cases:

    • a null heap with 0x1800 bytes and a non-null heap, which both return 0;
    • sceSharePlayTerminate, which returns 0;
    • a zero size, which throws with and without a heap.

    It passes 3 repeats. It was written first: on the earlier base 8b393b6e it aborted on the null-heap call without the change, and accepting a zero size fails it. tools/check_conventions.py --base upstream/main and git diff --check pass.

  • PPSA11386 v01.018.000, relinked on main 1476f769 and run in a bubblewrap sandbox. Without this branch the loader passes and the title stops with sceSharePlayInitialize: invalid argument. With it, the title continues and stops next on VideoOut: unsupported display pixel format 0xc001000622000000 (row 4 of #2523, SleglJan/AnyPS5#18).

  • Windows was last built and tested on the earlier base 8b393b6e, with head b175756b and the same code: fork run 37987894734, Windows 512/512 with guest_share_play passing.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fnrk5Dazjb2tLooVSpdRQq

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4813596415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2946). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T18:46:17Z. --- ### What `sceSharePlayInitialize` threw on a null heap. PPSA11386 (007 First Light) calls `sceSharePlayInitialize(NULL, 0x1800)` at start-up. On any non-zero result it logs `sceSharePlayInitialize() failed (0x%x)` and executes `int 0x42`. That is read at the call site in the relinked executable: `mov esi, 0x1800; xor edi, edi; call; test eax, eax; je` past the log and the trap. So the console accepts a null heap with a non-zero size. This implementation keeps no state and does not use the heap. A zero size still throws, because its error code is unknown. The null and zero checks came with #153. Recorded in TechnicalDebt. libSceSharePlay gets its own `CMakeLists.txt` for the test, modelled on libSceShare's. It links `libc` and calls `configure_windows_unwind`, because the test checks a throw. This is 007's next stop on `main` 1476f769, row 2 of #2523. Row 1 was #2830 and #2831, both now merged. Row 3 (#1921) is already passed on `main` by #1964, so with this change the title stops next on row 4. Overlap: no open pull request changes libSceSharePlay. ### Tested - Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), Ryzen 9 7950X3D, RTX 3080 (NVIDIA 615.71.09), Release with `BUILD_TESTING=ON` and `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, this branch on `main` 1476f769. Of 705 tests, 700 pass, four `video_out_flip_*` tests (lifetime, reopen, controls, overlay) skip (no Vulkan in SDL's offscreen video driver), and `agc_driver_dcc_keys_first_write` fails, which is #2767 (NVIDIA, Linux). - The new `guest_share_play` test covers three cases: - a null heap with 0x1800 bytes and a non-null heap, which both return 0; - `sceSharePlayTerminate`, which returns 0; - a zero size, which throws with and without a heap. It passes 3 repeats. It was written first: on the earlier base 8b393b6e it aborted on the null-heap call without the change, and accepting a zero size fails it. `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. - PPSA11386 v01.018.000, relinked on `main` 1476f769 and run in a bubblewrap sandbox. Without this branch the loader passes and the title stops with `sceSharePlayInitialize: invalid argument`. With it, the title continues and stops next on `VideoOut: unsupported display pixel format 0xc001000622000000` (row 4 of #2523, SleglJan/AnyPS5#18). - Windows was last built and tested on the earlier base 8b393b6e, with head b175756b and the same code: fork run [37987894734](https://github.com/SleglJan/AnyPS5/actions/runs/37987894734), Windows 512/512 with `guest_share_play` passing. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Fnrk5Dazjb2tLooVSpdRQq
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!2946
No description provided.