fix(libSceSysmodule): return INVALID_VALUE for module id 0 #3538

Merged
hugodearaujo merged 1 commit from upstream-pr/3538 into main 2026-10-11 21:32:25 +00:00
hugodearaujo commented 2026-10-11 12:40:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-11T12:40:05Z.


What

After sceHmd2Initialize fails, Propagation: Paradise Hotel (PPSA15878) unloads SCE_SYSMODULE_HMD2 with id 0, and main throws:

what():  sceSysmoduleUnloadModule: invalid id 0

Measured on a PS5 (firmware 13.60) with a payload that calls the console's libSceSysmodule:

Call Result
IsLoaded(0), LoadModule(0), UnloadModule(0) (twice) 0x805A1000
LoadModuleInternal, UnloadModuleInternal with 0 or 0x80000000 0x805A1000
LoadModuleInternalWithArg with 0 or 0x80000000 0x805A1000, *ret untouched
UnloadModule / IsLoaded on known modules that are not loaded (271, 272, 298) 0x805A1001, as main already returns

These six functions now return 0x805A1000 (SCE_SYSMODULE_ERROR_INVALID_VALUE) for id 0 instead of throwing. sceSysmoduleGetModuleHandleInternal was not measured and still throws.

The title expects this code. With this change its own log reads:

LogFireAnt: Warning: Failed to unload SCE_SYSMODULE_HMD2 with 0x805a1000.  Unless CreateInstance failed this suggests an object lifetime bug…

It then creates its Vulkan device, loads its shader library and stops later, in Initializing Engine, which is a separate problem.

Tested

  • PS5, firmware 13.60: the table above.
  • PPSA15878 on Linux, with #3537 for its imports: runs past the unload, as described above.
  • Linux: full CTest 832/832. guest_sysmodule now checks every row of the table; it aborts on main and passes with this change.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: full CTest 833/836; guest_kernel_sys, windows_exceptions and guest_filesystem exit with 0xc0000409 the same way on current main in this VM.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819111979 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3538). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-11T12:40:05Z. --- ### What After `sceHmd2Initialize` fails, Propagation: Paradise Hotel (PPSA15878) unloads `SCE_SYSMODULE_HMD2` with id 0, and `main` throws: ``` what(): sceSysmoduleUnloadModule: invalid id 0 ``` Measured on a PS5 (firmware 13.60) with a payload that calls the console's `libSceSysmodule`: | Call | Result | |---|---| | `IsLoaded(0)`, `LoadModule(0)`, `UnloadModule(0)` (twice) | `0x805A1000` | | `LoadModuleInternal`, `UnloadModuleInternal` with 0 or `0x80000000` | `0x805A1000` | | `LoadModuleInternalWithArg` with 0 or `0x80000000` | `0x805A1000`, `*ret` untouched | | `UnloadModule` / `IsLoaded` on known modules that are not loaded (271, 272, 298) | `0x805A1001`, as `main` already returns | These six functions now return `0x805A1000` (`SCE_SYSMODULE_ERROR_INVALID_VALUE`) for id 0 instead of throwing. `sceSysmoduleGetModuleHandleInternal` was not measured and still throws. The title expects this code. With this change its own log reads: ``` LogFireAnt: Warning: Failed to unload SCE_SYSMODULE_HMD2 with 0x805a1000. Unless CreateInstance failed this suggests an object lifetime bug… ``` It then creates its Vulkan device, loads its shader library and stops later, in `Initializing Engine`, which is a separate problem. ### Tested - PS5, firmware 13.60: the table above. - PPSA15878 on Linux, with #3537 for its imports: runs past the unload, as described above. - Linux: full CTest 832/832. `guest_sysmodule` now checks every row of the table; it aborts on `main` and passes with this change. - Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: full CTest 833/836; `guest_kernel_sys`, `windows_exceptions` and `guest_filesystem` exit with `0xc0000409` the same way on current `main` in this VM. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-11 12:50:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:50:22Z.


The current CI failures appear unrelated to this patch: the checks use base 1e8fff68c, where 3rdparty/imgui is an orphan gitlink without a .gitmodules URL. actions/checkout fails during cleanup with fatal: No url found for submodule path ... before compilation or convention checking. The same failure reproduces on PR #3535 and was fixed on main in #3511; rebasing onto the fixed base and rerunning checks should distinguish this environmental failure from any patch issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109201588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3538#issuecomment-6109201588). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T12:50:22Z. --- The current CI failures appear unrelated to this patch: the checks use base `1e8fff68c`, where `3rdparty/imgui` is an orphan gitlink without a `.gitmodules` URL. `actions/checkout` fails during cleanup with `fatal: No url found for submodule path ...` before compilation or convention checking. The same failure reproduces on PR #3535 and was fixed on main in #3511; rebasing onto the fixed base and rerunning checks should distinguish this environmental failure from any patch issue.
github-actions[bot] commented 2026-10-11 16:31:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T16:31:41Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#3716 core/libs/tests/GuestSysmodule.cpp L40-42, L100
#3769 core/libs/tests/GuestSysmodule.cpp L40-41
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111184811 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3538#issuecomment-6111184811). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T16:31:41Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #3716 | `core/libs/tests/GuestSysmodule.cpp` [L40-42](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/core/libs/tests/GuestSysmodule.cpp#L40-L42), [L100](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/core/libs/tests/GuestSysmodule.cpp#L100) | | | | #3769 | `core/libs/tests/GuestSysmodule.cpp` [L40-41](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/core/libs/tests/GuestSysmodule.cpp#L40-L41) | | |
adriadam10 commented 2026-10-11 21:32:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:32:21Z.


Checked the six id-0 paths against the table in the description, guest_sysmodule and guest_sysmodule_maps_scan pass, and guest_sysmodule fails when the Export.cpp change is reverted. CI on the current head is green; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114007611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3538#issuecomment-6114007611). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:32:21Z. --- Checked the six id-0 paths against the table in the description, `guest_sysmodule` and `guest_sysmodule_maps_scan` pass, and `guest_sysmodule` fails when the `Export.cpp` change is reverted. CI on the current head is green; merging.
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!3538
No description provided.