fix(libkernel): pass the first module arguments block to zero-argument sceKernelLoadStartModule calls #4296
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4296"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-12T05:09:31Z.
What
sceKernelLoadStartModulecalled withargs0 andargpnull now passes the first block that any call gave with a non-zeroargsand a non-nullargp(same pointer and size, not a copy, from any thread). A block that lies on the calling thread's stack is not remembered. The behaviour is recorded in TechnicalDebt.Three commits, kept separate for review (squash on merge is fine):
guest_load_start_module_args) and a fixture module;Fixes #4225. Blasphemous 2 (PPSA13579) loads
PSNCore.prxfrom its Il2CppUserAssemblies wrapper with hard-coded zeros.PSNCore's start reads a{0x10, 0x200, ptr}block, the one the engine passes when it loads Il2CppUserAssemblies, and without it prints "PSNCore is an old version that cannot be used by the current player runtime" and dereferences the null pointer. The engine fills the block only after the Il2CppUserAssemblies load, so a copy taken at that load is all zeros: PSNCore then still prints "found 0000" and runs without the engine's interface.Related: #918 (same PSNCore validator; that title passes a block), #1102 and #3492 (pass a load's own
args/argpon Linux and macOS). None covers(0, NULL)loads. Module.cpp is also edited by #4193 and #4219 (other functions; textual overlap only).What the console passes to a module started with zeros is not verified; this is a heuristic that reproduces what the title needs, listed in TechnicalDebt. Known limits: every later zero-argument load in the process gets the block (including
libfmodandlibfmodstudio), and it assumes the block outlives the module loads (the enginecallocs it once and keeps the pointer in a global).Tested
Linux (CachyOS, Release,
-j24), based onorigin/maind146ec1b6:python3 tools/check_conventions.py --base origin/main: all checks passedpython3 tools/check_test_registration.py build: 697 test executables, 0 built and not run as recordedctest -R 'guest_load_start_module_args|guest_module_args|guest_dynamic_loader|guest_module_info': 4/4 passedctest -R 'libkernel|kernel|guest_': 301 tests, 0 failed, 3 skipped (guest_video_out_*)app.elfrelinked by an earlier build; libraries from this branch): 3 runs of 240 s each, all ended by the timeout, no "old version" line, no SIGSEGV or abort, title screen ("Press ✕ to continue") at 59.94 FPS. Without #3295, 1 run passed the point where PSNCore starts (no "old version" line) and crashed after about 9 s during asset bundle loading, a separate bug (#4223, fixed by #3295).Windows and macOS: not built or run here. The new test is registered only outside Windows (
if(NOT WIN32)incore/libs/prx/libkernel/CMakeLists.txt): on Windows the fixture would have to link libkernel and export__aps5_get_pending_module_args_nid_no_patch, asguest_module_fixturedoes, and I could not build or verify that. The Windows CI run will compile theGetCurrentThreadStackLimitsbranch, but nothing here tests it. The macOS branch (pthread_get_stackaddr_np) is likewise unbuilt. The stack query duplicates the one inPthread/src/Thread.cpp, and a failed query treats the block as not on the stack.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (none added).mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-12T05:13:19Z.
Converting to draft. The checklist item "Generic behaviour, not specific to one title" can't be ticked honestly: replaying an earlier call's block to zero-argument loads comes from PPSA13579 alone, and libkernel normally hands
module_startonly the caller's ownargs/argp.There is a more likely root cause to check first. In PPSA28997 (#918) the Unity engine loads
Plugins/*.prxitself with the 0x34 block right afterIl2CppUserAssemblies. In PPSA13579 the engine never preloads any plugin, and our traces show no directory listing of/app0/Media/Pluginsat all, so only the il2cpp wrapper's zero-argumentPSNCoreload is left. If the engine skips the preload because of something AnyPS5 answers differently from the console, the generic fix belongs there. I'll report back on #4225; the test and analysis here stay for reference.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T07:20:28Z.
I checked the current implementation at
Module.cpp: eachsceKernelLoadStartModulecall setspendingModuleArgs = {args, argp}immediately beforedlopen, somodule_startreceives the current call’s arguments. This patch changes every subsequent(0, nullptr)load in the process to reuse the first earlier block, including unrelated modules, and the issue report says the console behavior is unknown. The title run demonstrates that this workaround reaches farther, but does not establish that the host should propagate arguments this way. I agree with keeping this draft until there is console/call-site evidence for the rule, or a narrower behavior supported by a general contract. The current test proves the proposed heuristic, not console compatibility.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T15:41:45Z.
Rebase handoff — rebased onto current
main, authorship unchanged (all three commits).Two
TechnicalDebt.mdconflicts, resolved by keeping main's adjacent entries plus this PR's entry in its refined final form (the second commit's version, with the stack-block clarification sentence).Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesTo pick it up:
Head is
2a5c6182c.Imported from boykopovar/AnyPS5. Originally posted by ducloc080202 on 2026-10-12T15:54:48Z.
Windows verification of the fix (the first one, as far as I can tell).
Environment. Windows 11, RTX 3050 Laptop (driver 617.42), WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, a full local build. I applied only theModule.cppchange from this PR (ResolveModuleArgs+IsOnCurrentThreadStack, including the_WIN32GetCurrentThreadStackLimitsbranch) onto currentmain, rebuiltlibkernel, re-ran the NID patcher, and ran a relinked commercial Unity title.Title. Cat Quest III (PPSA15065, Unity IL2CPP,
contentVersion01.000.001). Its bundled modules (sce_module/libc.prx,Media/Modules/*.prx,Media/Plugins/{PSN,SaveData,lib_burst_generated}.prx) were unwrapped from SELF/fSELF and relinked with--module-dir Media/Plugins --module-dir Media/Modules.Before the change (current
main): deterministic0xC0000005(read of0x4) inside the title's ownPSN.prx.guest.prx+0x13f37, immediately after it printsPSN is an old version that cannot be used by the current player runtime.— 2 of 2 runs.After the change: the
old versionline is gone. The title gets past PSN init and runs further (shader-disk-cache56 hits / 18 misses,sce::Agc::suspendPoint), then stops on a different, separate crash:0xC0000005(write of0x0) on threadLoading.PreloadManagerinapp.exe+0x7dfecb. That is the shape of #3805 (Hotline Miami,Loading.PreloadManager, null data pointer) and is unrelated to module arguments.Same mechanism as #4225 (the il2cpp wrapper loads the bundled PSN module with
(0, NULL)); on this title the plugin isPSN.prxrather thanPSNCore.prx, and, like PPSA13579, the engine never lists/app0/Media/Plugins. I left the same reproduction on #4225. This confirms the effect on Windows and exercises theGetCurrentThreadStackLimitsbranch, which the new test (registered only outside Windows) does not.I did not port the unit test to Windows. I can try — linking the fixture to libkernel and exporting
__aps5_get_pending_module_args_nid_no_patchthe wayguest_module_fixturedoes — if that would be useful here.Pull request closed