fix(libkernel): pass module arguments to loaded modules #4972

Closed
ducloc080202 wants to merge 4 commits from upstream-pr/4972 into main
ducloc080202 commented 2026-10-13 06:57:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ducloc080202 on 2026-10-13T06:57:44Z.


What

Rebases #4296 (closed unmerged) onto current main and resolves the docs/dev/TechnicalDebt.md conflict by keeping main's split debt files.

SceKernelLoadStartModule now remembers the first module-arguments block whose pointer does not lie on the calling thread's stack, and passes it to zero-argument module loads. Without this, modules that read their plugin arguments (e.g. Unity's PSN.prx version check) see garbage and can crash during startup: Cat Quest III (PPSA15065) crashed 4/4 boots in PSN.prx before this change.

Tested

  • Windows (MinGW 15.2.0, Release): full build passes; all 16 *module* ctests pass, including guest_module_args (the new test from this change builds and runs on Linux/macOS CI; the NOT_WIN32 guard is unchanged).
  • Cat Quest III (PPSA15065), Windows: before — deterministic early 0xc0000005 in PSN.prx.guest.prx after the "old version" error; after — boots past engine init and loads all 454 asset bundles to the loading screen. Linux/macOS rely on CI.

Checklist

  • Based on current main; no other open PR implements the same functions (#4296 is closed)
  • 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
  • Unblocks: boykopovar/AnyPS5#4909 (needed to reach the loading screen; the title still stalls there)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839577910 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4972). Originally posted by [ducloc080202](https://github.com/ducloc080202) on 2026-10-13T06:57:44Z. --- ### What Rebases #4296 (closed unmerged) onto current `main` and resolves the `docs/dev/TechnicalDebt.md` conflict by keeping `main`'s split debt files. `SceKernelLoadStartModule` now remembers the first module-arguments block whose pointer does not lie on the calling thread's stack, and passes it to zero-argument module loads. Without this, modules that read their plugin arguments (e.g. Unity's `PSN.prx` version check) see garbage and can crash during startup: Cat Quest III (PPSA15065) crashed 4/4 boots in `PSN.prx` before this change. ### Tested - Windows (MinGW 15.2.0, Release): full build passes; all 16 `*module*` ctests pass, including `guest_module_args` (the new test from this change builds and runs on Linux/macOS CI; the `NOT_WIN32` guard is unchanged). - Cat Quest III (PPSA15065), Windows: before — deterministic early `0xc0000005` in `PSN.prx.guest.prx` after the "old version" error; after — boots past engine init and loads all 454 asset bundles to the loading screen. Linux/macOS rely on CI. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#4296 is closed) - [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 under Silent stubs in their library's technical 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] Unblocks: boykopovar/AnyPS5#4909 (needed to reach the loading screen; the title still stalls there) - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 08:20:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:20:45Z.


Windows build check of this PR.

Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, BUILD_TESTING=ON, -j2, libusb-cmake from a local checkout. Built from main c2565f014 with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict.

Result: the merged tree builds, but no test of this PR runs on Windows: its tests (guest_load_start_module_args) are registered only for non-Windows builds in libkernel/CMakeLists.txt (if(NOT WIN32)).

Not checked: any behaviour of the change on Windows; no title run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141387217 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4972#issuecomment-6141387217). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T08:20:45Z. --- Windows build check of this PR. Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `BUILD_TESTING=ON`, `-j2`, `libusb-cmake` from a local checkout. Built from `main` `c2565f014` with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict. Result: the merged tree builds, but no test of this PR runs on Windows: its tests (`guest_load_start_module_args`) are registered only for non-Windows builds in `libkernel/CMakeLists.txt` (`if(NOT WIN32)`). Not checked: any behaviour of the change on Windows; no title run. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-14 06:19:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:19:00Z.


ResolveModuleArgs (Module.cpp) gives a load with no arguments the first arguments block an earlier load passed, picked by whether its pointer is on the caller's stack. That's a guess rather than what the kernel does, and it isn't allowed here. What does the console hand module_start when sceKernelLoadStartModule gets args == 0? If PSN.prx reads its arguments from somewhere else (the loading module's own arguments, for example), model that and throw on anything else.
The branch also has a merge commit; please rebase onto main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162225875 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4972#issuecomment-6162225875). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T06:19:00Z. --- `ResolveModuleArgs` (`Module.cpp`) gives a load with no arguments the first arguments block an earlier load passed, picked by whether its pointer is on the caller's stack. That's a guess rather than what the kernel does, and it isn't allowed here. What does the console hand `module_start` when `sceKernelLoadStartModule` gets `args == 0`? If `PSN.prx` reads its arguments from somewhere else (the loading module's own arguments, for example), model that and throw on anything else. The branch also has a merge commit; please rebase onto main.
oneandonlydean commented 2026-10-14 21:33:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T21:33:11Z.


Any news on the 10-14 point? ResolveModuleArgs hands a load with args == 0 an earlier load's arguments block, which is a guess rather than what the kernel does. What does the console pass to module_start in that case? Model that and throw on anything else, and please rebase onto main without the merge commit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6178979878 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4972#issuecomment-6178979878). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T21:33:11Z. --- Any news on the 10-14 point? `ResolveModuleArgs` hands a load with `args == 0` an earlier load's arguments block, which is a guess rather than what the kernel does. What does the console pass to `module_start` in that case? Model that and throw on anything else, and please rebase onto main without the merge commit.
github-actions[bot] commented 2026-10-15 12:07:12 +00:00 (Migrated from github.com)

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


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4563 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Module/src/Module.cpp
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6149 core/libs/prx/libkernel/Module/src/Module.cpp
PR 6226 core/libs/prx/libkernel/CMakeLists.txt
PR 6469 core/libs/prx/libkernel/CMakeLists.txt
PR 6519 core/libs/prx/libkernel/Module/src/Module.cpp
PR 6586 core/libs/prx/libkernel/CMakeLists.txt
PR 6830 core/libs/prx/libkernel/CMakeLists.txt
PR 6879 core/libs/prx/libkernel/Module/src/Module.cpp
PR 6893 core/libs/prx/libkernel/CMakeLists.txt
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
PR 6977 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Module/src/Module.cpp
PR 7090 core/libs/prx/libkernel/CMakeLists.txt
PR 7156 core/libs/prx/libkernel/CMakeLists.txt
PR 7192 core/libs/prx/libkernel/CMakeLists.txt
PR 7201 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Module/src/Module.cpp
PR 7299 core/libs/prx/libkernel/CMakeLists.txt
PR 7450 core/libs/prx/libkernel/CMakeLists.txt
PR 7532 core/libs/prx/libkernel/CMakeLists.txt
PR 7853 core/libs/prx/libkernel/CMakeLists.txt
PR 8041 core/libs/prx/libkernel/CMakeLists.txt
PR 8463 core/libs/prx/libkernel/CMakeLists.txt
PR 8477 core/libs/prx/libkernel/CMakeLists.txt
PR 8487 core/libs/prx/libkernel/CMakeLists.txt
PR 8520 core/libs/prx/libkernel/CMakeLists.txt
PR 8626 core/libs/prx/libkernel/CMakeLists.txt
PR 8658 core/libs/prx/libkernel/CMakeLists.txt
PR 8700 core/libs/prx/libkernel/CMakeLists.txt
PR 8717 core/libs/prx/libkernel/CMakeLists.txt
PR 8726 core/libs/prx/libkernel/CMakeLists.txt
PR 8850 core/libs/prx/libkernel/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191660164 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4972#issuecomment-6191660164). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:07:12Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 4563](https://www.github.com/boykopovar/AnyPS5/pull/4563) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Module/src/Module.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `core/libs/prx/libkernel/Module/src/Module.cpp` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6519](https://www.github.com/boykopovar/AnyPS5/pull/6519) | `core/libs/prx/libkernel/Module/src/Module.cpp` | | [PR 6586](https://www.github.com/boykopovar/AnyPS5/pull/6586) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6830](https://www.github.com/boykopovar/AnyPS5/pull/6830) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libkernel/Module/src/Module.cpp` | | [PR 6893](https://www.github.com/boykopovar/AnyPS5/pull/6893) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Module/src/Module.cpp` | | [PR 7090](https://www.github.com/boykopovar/AnyPS5/pull/7090) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7156](https://www.github.com/boykopovar/AnyPS5/pull/7156) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Module/src/Module.cpp` | | [PR 7299](https://www.github.com/boykopovar/AnyPS5/pull/7299) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7450](https://www.github.com/boykopovar/AnyPS5/pull/7450) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7532](https://www.github.com/boykopovar/AnyPS5/pull/7532) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7853](https://www.github.com/boykopovar/AnyPS5/pull/7853) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8041](https://www.github.com/boykopovar/AnyPS5/pull/8041) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8463](https://www.github.com/boykopovar/AnyPS5/pull/8463) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8477](https://www.github.com/boykopovar/AnyPS5/pull/8477) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8487](https://www.github.com/boykopovar/AnyPS5/pull/8487) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8520](https://www.github.com/boykopovar/AnyPS5/pull/8520) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8626](https://www.github.com/boykopovar/AnyPS5/pull/8626) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8658](https://www.github.com/boykopovar/AnyPS5/pull/8658) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8700](https://www.github.com/boykopovar/AnyPS5/pull/8700) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8717](https://www.github.com/boykopovar/AnyPS5/pull/8717) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8726](https://www.github.com/boykopovar/AnyPS5/pull/8726) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 8850](https://www.github.com/boykopovar/AnyPS5/pull/8850) | `core/libs/prx/libkernel/CMakeLists.txt` |
oneandonlydean commented 2026-10-21 04:52:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T04:52:34Z.


Thanks for this. Since the questions from 14 Oct are still open and it has gone quiet, I'm closing it for now to keep the queue current. Please reopen it once you've had a chance to address them, and we'll pick it up.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308349854 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4972#issuecomment-6308349854). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T04:52:34Z. --- Thanks for this. Since the questions from 14 Oct are still open and it has gone quiet, I'm closing it for now to keep the queue current. Please reopen it once you've had a chance to address them, and we'll pick it up.

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