fix(sysmodule): acquire native providers before reporting loaded #1061

Closed
eliasbruno124-dev wants to merge 1 commit from upstream-pr/1061 into main
eliasbruno124-dev commented 2026-10-07 07:00:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-07T07:00:43Z.


What

Sysmodule reports a successful load after incrementing a counter without acquiring a native provider image. Unknown public IDs also report success, and the WithArg path ignores its payload.

Acquire the mapped provider through the existing libkernel loader from libs/ beside the executable. Publish loaded state only after acquisition, share references between public/internal calls, and release the owned loader reference at final unload. Native initialization/finalization run outside the state lock; callbacks can query state during both transitions. Independent native and dynamic-loader references remain owned by their callers.

Missing/invalid images, failed attachment, unknown IDs, transitions in progress, reference overflow and nonempty WithArg payloads fail explicitly. Add the 0x125 TextToSpeech2 ID from the pinned public PS5 module table. This supplies native transport and ID routing, not a speech implementation.

Console module-start/module-stop entry points, version negotiation and nonempty load arguments remain unimplemented; TechnicalDebt records the limits.

The overlap report with #846 concerns declarations and calls of the existing dlopen_nid_postfix; this PR does not change its implementation or define another loader export. #1055 adds an unrelated AGC entry at the same TechnicalDebt insertion point. Neither is a functional dependency of this native-provider change. If either merges first, rebase this branch and retain both debt entries. Combined native execution with #846 has not been tested.

Tested

Windows, MinGW-w64 GCC 15.2.0, Release/Ninja. Rebased onto main at 78b8f058fbd89477eb1806d0551e8b79f512933b, then rebuilt the affected provider, loader and fixtures from final commit 11730063 with unchanged source inputs.

  • guest_sysmodule: 20 native process cases, ten each for Fiber and TextToSpeech2 identities. Checks actual image acquisition/final release, preloaded images, shared loader ownership, missing/invalid images, failed attachment, unknown load/query/unload IDs and nonempty arguments. Positive cases require native image presence and an attach/detach pair; negative cases require explicit diagnostics and native aborts.
  • guest_dynamic_loader and guest_elf_phdr_match: both existing adjacent groups passed with the rebuilt dependencies. The final selection passed all three groups.
  • Earlier unchanged-production tests reproduced success without a loaded image and rejection of TextToSpeech2 ID 293. The upstream Sysmodule sources are unchanged since those baselines; the historical receipts remain separate.

Native Linux execution is untested. The provider fixture is not TextToSpeech2 emulation. The previous local Shadows integration still stopped at missing libSceTextToSpeech2.prx (0xC0000135); this contribution was not retested in the title and claims no menu, gameplay or performance improvement.

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; no silent success fallback
  • No investigation files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4769142242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1061). Originally posted by [eliasbruno124-dev](https://github.com/eliasbruno124-dev) on 2026-10-07T07:00:43Z. --- ### What Sysmodule reports a successful load after incrementing a counter without acquiring a native provider image. Unknown public IDs also report success, and the WithArg path ignores its payload. Acquire the mapped provider through the existing libkernel loader from `libs/` beside the executable. Publish loaded state only after acquisition, share references between public/internal calls, and release the owned loader reference at final unload. Native initialization/finalization run outside the state lock; callbacks can query state during both transitions. Independent native and dynamic-loader references remain owned by their callers. Missing/invalid images, failed attachment, unknown IDs, transitions in progress, reference overflow and nonempty WithArg payloads fail explicitly. Add the `0x125` TextToSpeech2 ID from the pinned [public PS5 module table](https://github.com/astrelsky/libNidResolver/blob/3f7ce7086c38ef35eb7869aafb247ed544ae3ee1/source/sysmodules.c). This supplies native transport and ID routing, not a speech implementation. Console module-start/module-stop entry points, version negotiation and nonempty load arguments remain unimplemented; TechnicalDebt records the limits. The overlap report with #846 concerns declarations and calls of the existing `dlopen_nid_postfix`; this PR does not change its implementation or define another loader export. #1055 adds an unrelated AGC entry at the same TechnicalDebt insertion point. Neither is a functional dependency of this native-provider change. If either merges first, rebase this branch and retain both debt entries. Combined native execution with #846 has not been tested. ### Tested Windows, MinGW-w64 GCC 15.2.0, Release/Ninja. Rebased onto `main` at `78b8f058fbd89477eb1806d0551e8b79f512933b`, then rebuilt the affected provider, loader and fixtures from final commit `11730063` with unchanged source inputs. - `guest_sysmodule`: 20 native process cases, ten each for Fiber and TextToSpeech2 identities. Checks actual image acquisition/final release, preloaded images, shared loader ownership, missing/invalid images, failed attachment, unknown load/query/unload IDs and nonempty arguments. Positive cases require native image presence and an attach/detach pair; negative cases require explicit diagnostics and native aborts. - `guest_dynamic_loader` and `guest_elf_phdr_match`: both existing adjacent groups passed with the rebuilt dependencies. The final selection passed all three groups. - Earlier unchanged-production tests reproduced success without a loaded image and rejection of TextToSpeech2 ID 293. The upstream Sysmodule sources are unchanged since those baselines; the historical receipts remain separate. Native Linux execution is untested. The provider fixture is not TextToSpeech2 emulation. The previous local Shadows integration still stopped at missing `libSceTextToSpeech2.prx` (`0xC0000135`); this contribution was not retested in the title and claims no menu, gameplay or performance improvement. ### 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; no silent success fallback - [x] No investigation files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-07 07:15:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T07:15:22Z.


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
#846 dlopen_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6032951863 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1061#issuecomment-6032951863). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T07:15:22Z. --- <!-- 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 | |---|---|---|---| | #846 | | `dlopen_nid_postfix` | |
oneandonlydean commented 2026-10-07 09:00:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-07T09:00:42Z.


Thanks for the detailed write-up and the native test fixture. I'm closing it for now, because it changes what every title gets from sysmodule and no title is shown to need that:

  • In this project a module's exports are bound by the relinker through the executable's imports from libs/*.prx; sceSysmoduleLoadModule doesn't need to map anything for the title to call into the module. Reporting a load as successful is therefore not a missing step on main.
  • After this change, every load of a module without its own libs/<name>.prx throws. About 200 of the 268 names in ModuleTable.hpp have no library in core/libs/prx, so titles that load one of them today and carry on would now stop at boot. The .native libraries are also built as <name>.native.prx, which this lookup never finds.
  • Unknown ids are logged and accepted on main on purpose; the owner made that change in b4db9fdd6. This PR makes them throw again.
  • sceSysmoduleLoadModuleInternalWithArg now throws for any nonzero unk, and nobody has checked which values titles pass there.
  • The path is fixed to libs/ beside the executable, so it ignores a custom --rpath.
  • It hasn't been run on Linux or in a title, and the description says the title you tested still stops at the missing libSceTextToSpeech2.prx. That failure happens when the import is loaded, not in sysmodule.

If a title misbehaves on main because sysmodule reports success, please open an issue or a new PR with the title ID and the log line where it stops. Adding id 0x125 → libSceTextToSpeech2 to the table on its own is fine as a small PR once a title loads that id.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6034592521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1061#issuecomment-6034592521). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-07T09:00:42Z. --- Thanks for the detailed write-up and the native test fixture. I'm closing it for now, because it changes what every title gets from sysmodule and no title is shown to need that: - In this project a module's exports are bound by the relinker through the executable's imports from `libs/*.prx`; `sceSysmoduleLoadModule` doesn't need to map anything for the title to call into the module. Reporting a load as successful is therefore not a missing step on main. - After this change, every load of a module without its own `libs/<name>.prx` throws. About 200 of the 268 names in `ModuleTable.hpp` have no library in `core/libs/prx`, so titles that load one of them today and carry on would now stop at boot. The `.native` libraries are also built as `<name>.native.prx`, which this lookup never finds. - Unknown ids are logged and accepted on main on purpose; the owner made that change in b4db9fdd6. This PR makes them throw again. - `sceSysmoduleLoadModuleInternalWithArg` now throws for any nonzero `unk`, and nobody has checked which values titles pass there. - The path is fixed to `libs/` beside the executable, so it ignores a custom `--rpath`. - It hasn't been run on Linux or in a title, and the description says the title you tested still stops at the missing `libSceTextToSpeech2.prx`. That failure happens when the import is loaded, not in sysmodule. If a title misbehaves on main because sysmodule reports success, please open an issue or a new PR with the title ID and the log line where it stops. Adding id `0x125` → `libSceTextToSpeech2` to the table on its own is fine as a small PR once a title loads that id.

Pull request closed

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!1061
No description provided.