loader: load the bundled PRXs the executable imports at startup #1366
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1366
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1366"
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?
@LukaszRozmej on GitHub · 2026-10-10 11:26 UTC · original
LukaszRozmej:fix/load-imported-bundled-prx→main· +35 −1 · 2 files · 2 commits · openProblem
Only
/app0/sce_module/libc.prxis loaded automatically. Other bundled modules theexecutable imports from are never loaded unless the game requests them, so every import from
them is bound to a stub that returns 0.
Astro Bot (PPSA21564) ships
sce_module/libSceNpCppWebApi.prx, and itseboot.binimports 802NpCppWebApifunctions directly. The game never asks for the module, so it runs on stubs:Fix
For each module the executable imports, load
sce_module/<module name>.prxif it exists,next to libc, and start it after libc.
libc.prxexportslibc, andlibSceNpCppWebApi.prxexportslibSceNpCppWebApi.DT_STRTABrather thanDT_OS_STRTAB, so the names comefrom the already-loaded executable's import list; the PRX isn't opened unless it's imported.
Resolve, so this only fills imports Kyty doesn'timplement.
Risk
Games that bundle other PRXs they import will now load them and run their
module_startatboot. That's what fixes the stubbed imports, but a module whose initializer needs something
Kyty doesn't implement yet would now fail at startup instead of later. Happy to gate this
differently if you prefer.
Testing
main(307fdcf).libSceNpCppWebApi.prxloads, relocates and starts, and theUnresolved import stub calledcount drops from 4 to 0. That run used the same change on7b9997b; on currentmainI've verified the build only.Only /app0/sce_module/libc.prx was loaded automatically. Other bundled modules the executable imports from, such as libSceNpCppWebApi.prx in Astro Bot (PPSA21564), were never loaded unless the game requested them, so their functions were bound to stubs returning 0 ("Unresolved import stub called: ...[NpCppWebApi_v1]"). Load sce_module/<module name>.prx for every module the executable imports, next to libc, and start them after libc. A bundled PRX is named after the module it exports (libc.prx exports libc, libSceNpCppWebApi.prx exports libSceNpCppWebApi). HLE symbols still take precedence when resolving.@coderabbitai[bot] on GitHub · 2026-10-10 11:32 UTC · original · edited 2026-10-12 14:20 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
3b2d42e7-819a-4fe2-9cea-bffc85c7d082📥 Commits
Reviewing files that changed from the base of the PR and between
0c16598752and1357fc5c30.📒 Files selected for processing (1)
src/loader/runtimeLinker.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
RuntimeLinkerfinds imported modules for the first non-shared program and loads matching PRX files from a supplied folder when they exist and are not already loaded.Executeuses libc’s directory for this lookup. After relocation, it starts each loaded bundled module with a nonzero initializer.Priority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
1357fNo established issue remains that prevents merging after normal checks.
Pre-merge checks |
4 |
1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -1220,0 +1237,4 @@if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {modules.push_back(LoadProgram(path));}}@coderabbitai[bot] on GitHub · 2026-10-10 11:32 UTC · original · edited 2026-10-12 14:18 UTC
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1182
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10113
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5617
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 13144
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6328
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5441
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2151
Constrain imported module names to a plain filename.
imported.nameis copied from the ELF dynamic string table without validation. A name such as../../outsideor an absolute path can escapefolder.IsFileExistingchecks the resulting path, andLoadProgramopens that same path.Executethen starts the loaded module. A valid PRX outside the bundled directory can therefore be loaded.Reject path components and root-qualified names before joining the path. A substring check for
..is broader than required; the filename check already prevents traversal.Suggested fix
📝 Committable suggestion
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3206
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 33935
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 33901
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 33652
🌐 Web query:
KytyPS5 runtimeLinker.cpp LoadImportedBundledModules LoadProgram💡 Result:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15708
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 13888
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4905
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4580
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2008
Load the bundled PRX dependency closure before relocation.
When a bundled PRX imports another bundled PRX that is not listed by the executable,
LoadImportedBundledModulesdoes not load the transitive dependency.LoadProgramloads only the requested ELF and does not recurse. If the dependency's symbol is not provided by HLE or another loaded export, relocation sets its address to zero and patches function imports toUnresolvedImportStub, which returns zero. This can break the importing PRX or its initializer.Suggested fix
📝 Committable suggestion
✅ Confirmed as addressed by @LukaszRozmej
@coderabbitai[bot] on GitHub · 2026-10-10 11:32 UTC · original · reviewed
Actionable comments posted: 2
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
94280364-be65-475e-8b7f-f0025537398c📥 Commits
Reviewing files that changed from the base of the PR and between
307fdcf7adand0c16598752.📒 Files selected for processing (2)
src/loader/runtimeLinker.cppsrc/loader/runtimeLinker.hIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@ -1220,0 +1237,4 @@if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {modules.push_back(LoadProgram(path));}}@LukaszRozmej on GitHub · 2026-10-12 14:18 UTC · original
Fixed in
1357fc5: the import name plus.prxmust be a plain file name (filename() == path), which rejects.., separators and root-qualified names on both platforms.@ -1220,0 +1237,4 @@if (Common::File::IsFileExisting(path) && FindProgramByFileName(path) == nullptr) {modules.push_back(LoadProgram(path));}}@coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original
@LukaszRozmej, thanks for the fix. The supplied code checksfilename() == file_namebefore joining the path tofolder. This addresses the path traversal finding.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@socket1001 on GitHub · 2026-11-19 16:05 UTC · original
Astro Bot (PPSA21564) data point for this PR — crash inside the bundled-PRX load path on two builds.
Environment: Linux (Ubuntu 26.04, kernel 7.0), AMD RX 9070 / RADV (Vulkan 1.3+), official release builds.
Dump: DUPLEX dump of the retail title (fresh usenet re-download, SFV-verified),
PPSA21564-app0withsce_module/(10 modules incl.libSceNpCppWebApi.prx),data/,eboot.bin(251 MB).What happens (identical on KytyPS5-2026-11-17-faec1f4 and the pre-regression KytyPS5-2026-09-28-8e61798 from #1070):
So the emulator gets through init, Vulkan pipeline cache, title detection and starts compiling shaders, then dies on a null dereference in the loader thread that services module loads — which looks like the same code path this PR is about (the game's eboot imports ~800
NpCppWebApifunctions, and the load of the bundled modules appears to be what trips the fault).Register context at fault:
rdi=0x9101942b8 rsi=0x707f20000930 r13=0x0, faulting instruction is a call withrcx=deadbeef00000007(poison value) — suggesting an uninitialized/garbage function pointer rather than a data NULL.Two notes that may help triage:
sce_module/also shipslibScePfs.prx,libSceFontGsm.prx,libSceJobManager.prx,libSceNpCppWebApi.prxetc. — Astro's module import surface is larger than the single-libccase the current loader handles.Unresolved import stub calledline before the fault, so the crash happens during/before binding, not after binding to stubs.Happy to test a build that changes the module load order or guards
runtimeLinker.cpp:719, and can provide the full emulator log or a repro command line (kyty_emulator --game <dir>) on request.(Comment prepared with AI assistance; tested and verified on hardware by me.)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.