Repository navigation
fix(libkernel): resolve original .prx names to relinked .guest.prx in stat, open and reachability - #4688
Conversation
… stat, open and reachability Titles check for a plugin with sceKernelStat before loading it through the engine path. The relinker emits only X.prx.guest.prx, so the check failed and PSNCore started with the raw (0, NULL) arguments. Share the dlopen mapping with sceKernelStat, read-only sceKernelOpen and sceKernelCheckReachability when the original name is absent.
| std::filesystem::path PathOrRelinkedModule(const std::filesystem::path& nativePath) { | ||
| std::error_code error; | ||
| if (std::filesystem::exists(std::filesystem::symlink_status(nativePath, error))) return nativePath; | ||
| return RelinkedModulePath_nid_no_patch(nativePath); |
There was a problem hiding this comment.
std::filesystem::exists(file_status) is false when file_status is not_found, which is what symlink_status returns for a dangling symlink. That means a dangling original path is not preserved here as the PR description says; if a sibling <path>.guest.prx exists, stat/open/reachability will be redirected to it. Could this test the symlink_status type (or otherwise preserve every existing directory entry) and add a regression with a dangling original symlink plus a relinked sibling?
|
Windows test of this PR. Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Result: Not checked: whether the new test fails without the change to the library code (I ran only the PR as submitted); no title run. I did not build on the current AI-assisted (Claude Code). |
… lstat #4688 made stat, sceKernelStat, read-only open and sceKernelCheckReachability find X.guest.prx when a title asks for X, the name the relinker replaced. lstat still answered ENOENT for the same path, so a title that stats a plugin with lstat saw it missing while stat and dlopen found it. lstat now resolves the name the same way; an existing X, including a dangling symlink, is still reported as is.
What
Refs #4225.
Titles that ship a plugin check for it with
sceKernelStatbefore loading it. The relinker emits only<name>.prx.guest.prx, sosceKernelStat("/app0/Media/Plugins/PSNCore.prx")returned ENOENT, whiledlopenalready mapsXtoX.guest.prx. Blasphemous 2 (PPSA13579): the il2cpp find-plugin callback (eboot 0xa46860) stats the plugin and only on success takes the engine load path that passes the{0x10, 0x200, getInterface}block tosceKernelLoadStartModule. After the failed stat the title falls back to a baresceKernelLoadStartModule(path, 0, NULL), PSNCore'smodule_startrejects the missing block ("PSNCore is an old version") and dereferences NULL.This moves the
X -> X.guest.prxrule out ofdlopeninto one helper,RelinkedModulePath_nid_no_patch(libc, next toResolvePath_nid_no_patch). libkernel wraps it asFile::PathOrRelinkedModule, which keepsXwhen it exists (including a dangling symlink) and otherwise returnsX.guest.prxif that file exists.dlopen,sceKernelStat(andstat), read-onlysceKernelOpenandsceKernelCheckReachabilityuse it. Open with write orO_CREATis unchanged. No module arguments are replayed.Alternative to my draft #4296 (module-argument replay), which this makes unnecessary for PPSA13579; I will close #4296 once this is merged.
Not covered, behaviour unchanged:
lstat,access, directory listings.Tested
Linux x86-64 (Release), Blasphemous 2 PPSA13579 relinked with the stock relinker,
app0/Media/Pluginsholding only*.prx.guest.prx, no symlinks, #4296 not applied.TestRelinkedModuleNamesinGuestFilesystem.cppfails without the change (aborts at the first relinked stat,GuestFilesystem.cpp:188) and passes with it.ctest -j4 --timeout 120on the branch rebased onto 1acfa7f (the final rebase onto a60f52e only adds workflow and CONTRIBUTING changes): 971 tests, 0 failures, 10 skipped (no display);check_skips.py(10 skips, all expected),check_test_registration.py(730 executables, none new) andcheck_conventions.py --base origin/main --head HEADpass. Not run: Windows and macOS builds.Plugins/PSNCore.prxnow returns 0, the engine load site is reached, no "old version" message. Onmainplus this change alone the title then crashes with SIGSEGV (eboot 0x4430ae,core::string::reserve) while loading Addressables bundles, 2 of 2 runs: this is the guestsceKernelClose(0)/ host fd 0 reuse fixed by fix(libkernel): keep host standard streams open on guest close #3295 (and also hit with fix(libkernel): pass the first module arguments block to zero-argument sceKernelLoadStartModule calls #4296 alone). With fix(libkernel): keep host standard streams open on guest close #3295 added locally, 2 runs of 240 s hold the title screen at ~59.9 FPS with no crash. Only the title screen was checked, no input sent.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)