fix(loader): defer Linux runtime module starts until requested #6586
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6586"
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 JJenkx on 2026-10-15T21:23:46Z.
What
Double Dragon Gaiden (PPSA16018, 01.000.013) historically stopped before main when a linked Unity plugin started through Linux
DT_INITwithout engine context. This change keeps explicit runtime-directory modules mapped for bindings and starts each module when the title explicitly loads it, forwarding the caller's exact argument pair, including zero/null.The Linux loader initializes each requested module once, returns the entry result to the load that performs initialization, handles concurrent/reentrant loads, and runs generated finalizers only after initialization completes. Standard SDK folders keep eager initialization, including browser conversions. Present zero-address
DT_INITentries retain their relocation; absent tags leave a null lifecycle slot. No title-specific contexts or default argument blocks are supplied.Rebased onto main
d6eafa54d0464258574fd2f71889754d05a5bc93, headfa3e35112131790755dcddadc54cf2c7b8dea37e. Prerequisite #6684 is merged; this branch contains only the fourteen topic commits, with no merge commits. The rebase preserves the production and test changes; range-diff differences are documentation context. A merge-tree check against newer main7e2ba73e4c8c26b5d632b0d2f46166ffc1b8a29dis clean, and conventions pass against it. Build and test results below apply to the statedd6eafa54base.Review focus: initialization timing for linked runtime-directory modules and repeated-load result semantics. Uniform Windows deferral was accepted in the #8162 review; that is related design precedent, not a console measurement or approval of this Linux implementation. An additional real-kernel diagnostic on production-source head
cea585242429fe0e20df3a92d670fa51e8a6437dobserved entry result0x5a17for the first load and0for a repeated load, including a concurrent waiter; the entry and init array still ran once. Console repeated-load result semantics are unmeasured, so result retention across subsequent loads is not claimed. Earlier integration runs reached Double Dragon Gaiden character selection; gameplay is not established. Evergate remained black with and without the change. Those title observations are historical and were not rerun on this head.Tested
Current-main refresh, 2026-10-23: head
2c98914fe4d95fc406b585c377412c7b48675bdcis a linear 14-commit rebase onto pinned main4997726a5f6b8cd263461508945a4676647ef482. The only conflict was thedlopenload-failure block: this refresh preserves main'sLoadFailurediagnostics and keeps deferred initialization after a successful load. The existing reentrancy, nested-handle, unload/reload and real condition-wait coverage is retained.Fresh Linux GCC 16.2.1 Release, independent worktree/build with exact submodules:
guest_runtime_lifecyclepasses three consecutive repetitions, andrelinker_conversionpasses three consecutive repetitions, with no skips. The relinker and lifecycle probe are freshly built. Conventions and whitespace checks pass. These are CPU synthetic module/loader and conversion regressions; no new native title, Windows, GPU or performance result is claimed. The existing documented lifecycle/ABI limitations remain.Arch Linux x86-64, GCC 16.2.1, Ryzen 9 7950X. Results below distinguish the public test head from the private runtime integration.
fa3e35112131790755dcddadc54cf2c7b8dea37e, clean-configured and built the relinker, all runtime libraries (libs) andguest_runtime_lifecycle_tests. Passed 239/239 relinker tests and the real-kernel lifecycle wrapper covering all six modes: never-start, start, zero-start, concurrent, reentrant and reload. No failures or skips. The concurrent initializer remains blocked until the second loader thread enterspthread_cond_wait, and the test requires that wait to return. This wrapper is confined to the Linux test executable. Source and artifact hashes were independently checked; conventions and whitespace checks pass. This is not the complete runtime test suite.fcf647f928390b33f0fa21374c136d3ed72f8236687078e80a2d376fdd1cb1cd.PPSA19591) on that pinned private integration passed the narrated opening and prologue selection, rendered the stagecoach scene, and reached the party tutorial. The 573-second run exited 0 after the scheduled ordinary window close at 571 seconds; the temporary kernel limit was restored to 64 MiB. Screenshots at 300/450/550 seconds show those scenes. Combat, overall rendering correctness and performance remain unverified.3bfa3c0f62f8257ef7dd6980c52077b16442c182c4f426954f1abbfd1c3d0b80.624609bfe2: relinker jobs pass on Linux, Windows and both macOS configurations; relinker ASan passes. These do not establish full Windows/macOS runtime or runtime sanitizer coverage. Full Linux/Windows jobs were skipped in the automatic PR workflow. The current upstream workflow runs them on main or via manual workflow dispatch; marking this ready for review does not trigger them. A maintainer-run full build is still requested.Earlier validation at its recorded revisions: 238/238 relinker tests passed; the reentrant negative control deadlocked when only the same-thread reentrancy return was removed; unload/reload coverage confirmed mapping removal and one finalizer sequence per initialized lifetime. Nested-handle regression and negative-control evidence, unload/reload evidence, and earlier full relinker validation.
No full runtime suite, Windows/macOS runtime, runtime sanitizer, GPU-validation or performance result is claimed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-16T04:50:43Z.
Hi @JJenkx, a heads-up on how this interacts with #6684. That PR runs a guest DT_INIT of 0 as the module initializer, for the bundled
libc.prx/libSceFios2.prxof PS4 Until Dawn (CUSA02636), where tag 12 is present with value 0. It addsGuestImage::HasInit, set when tag 12 is present, and the writers test it instead ofInit != 0.Merging the two:
passesModuleArgsinLinuxGuestModuleWriter.cpp(L32). I resolved it asimage.HasInit && !deferInitialization.pointer(image.Init, image.Init != 0);(L98 at 8838a92bb) becomespointer(image.Init, image.HasInit);. Otherwise a deferred module whose DT_INIT is 0 gets no relocation for lifecycle slot 2.InitializeLinuxGuestModulethen seestable[2] == 0(DynamicLoader.cpp L144) and skips the initializer, recording result 0 with no error.I checked this on
main5d9dcc42d+ #6684 + 8838a92bb (relinker-only build) with a--module-dir pluginsmodule whose DT_INIT is 0. With only the textual resolution, the slot at table+0x10 has no relocation. With the one-line change it getsR_X86_64_RELATIVE(0x4010, addend 0). The relinker-only suite passes 183/183 either way, so it won't catch this. Whichever PR lands second needs that line. If this one lands first, I'll add it to #6684.AI Assisted
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-16T05:05:12Z.
Addressed in
6c8ff59838b5dfcff2cf64cd32e71eb1dff415ce. The branch is refreshed onto current main5d9dcc42dplus #6684 (ab9d21afcfbc, authorship retained), now declared as a prerequisite. The textual resolution usesimage.HasInit && !deferInitialization, and lifecycle slot 2 now usespointer(image.Init, image.HasInit).I extended
guest_zero_initializerwith deferred Linux cases: DT_INIT zero with/without preinit, native initializer argument/return verification on Linux x86-64, and an absent-tag control. The new regression fails on the textual-resolution-only tree becausetable+0x10has no relocation. With the one-line correction, the relinker-only build and all 183/183 tests pass; conventions/whitespace pass. No fresh full-runtime/title run on this head. The PR remains a draft for the existing initialization-timing review.Windows CI then exposed a test-fixture portability issue (a Windows host path supplied as a Linux guest run path). Fixed in
a17a8daf10acc9fbbf192b92e7b9ad0ae3e82bbfby using$ORIGIN/libs; the production initializer correction is unchanged. All 183 local tests pass again. The fresh GitHub relinker matrix now passes Linux, Windows and macOS on this exact head. Full runtime builds were skipped.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-16T07:09:11Z.
Temporarily closing this draft to free a slot under the project's 20-open-PR limit for the validated ATRAC9 vibration startup fix. The source branch fix/linux-runtime-module-start is retained at a17a8daf10acc9fbbf192b92e7b9ad0ae3e82bbf for later reopening. The zero-DT_INIT feedback is addressed and its relinker checks pass; the initialization-timing review remains outstanding.
Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-19T02:35:32Z.
@JJenkx heads-up, since this carries #6684's first commit: with #6112 reverted, I've updated #6684 by merging
mainand adding two commits.0500362ffaddsadd_asan_test_options(guest_zero_initializer verify_asan_link_order=0).f77a9eaa0changes #6106's check inGuestModuleBuilder.cpp(images[index].Init != 0, which adds thelibkernel.prxdependency the Linux DT_INIT stub imports from) toHasInit. Without it, a converted module with DT_INIT 0 gets the stub but not the dependency, and loading it fails withundefined symbol: __aps5_get_pending_module_args_nid_no_patch. The test now copies the host tolibs/libkernel.prxand checks that dependency. Your copy (2197de555) predates #6106, so it doesn't have this.I replayed your branch onto
mainplus updated #6684 locally. The first five of your own commits apply cleanly, and25266b497has one conflict intest_guest_zero_initializer.py, where both add lines around the native load. After #6684 lands, the rebase should drop2197de555as already applied.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-19T02:44:35Z.
Updated to main
8a526d4495and carried all three topic commits from #6684 atf77a9eaa08, preserving authorship and omitting its merge commit. The HasInit dependency check and ASan host-loading option are retained. The deferred zero-initializer fixture now supplies libkernel.prx and checks dependency presence for present/absent DT_INIT.At 85b281b22c: 149/149 relinker-directory CTests and all four focused loader/initializer tests pass without skips; conventions and whitespace pass. Local ASan execution was not tested. The PR remains draft for lifecycle-timing review. Thanks for identifying the dependency update.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-20T16:30:43Z.
Rebased without merge commits onto main
f6ce8e34a20a9d6728a728c4769335ecaf5edea0and pushed heade643956fb984a8f0378985fe56949c6331df9534.Resolved the GuestModuleWriter/GuestModuleBuilder conflicts by retaining main's Windows/macOS message callbacks and this branch's deferred Linux runtime start. Updated main's new unused-import dependency regression to distinguish mapping from initialization: its dependency/export assertions remain, startup records no plugin initializer, and explicit initialization checks the argument pair and return result.
Rebuilt: 161/161 relinker tests and 4/4 focused lifecycle tests pass, no skips; conventions/whitespace pass. #6684 remains the unchanged prerequisite at
f77a9eaa086166d9417b2d31a39a80efd815c2a3. Still draft pending lifecycle review; no new native title or performance claim. AI-assisted: yes.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T13:35:10Z.
Rebased the ten topic commits without merge commits onto main
27bcd6a29e2fd69aba0626610b2350eb8f2847f6, now headcea585242429fe0e20df3a92d670fa51e8a6437d. The conflicts were in documentation: main’s newer Windows executable-module deferral is preserved, and the usage/debt entries distinguish it from this branch’s Linux behavior. Source/test patches are preserved by range-diff.At this head: 238/238 relinker tests and 1/1 real-kernel runtime lifecycle test passed, with conventions and whitespace checks passing. A merge-tree check is clean against newer main
80565c59424190cd0f660f8097945443a0017c42; the test results apply to the stated head. No new native title, Windows or performance result is claimed. Still draft pending initialization-timing review.Logs, patch and range-diff, SHA-256
802e470b86e6b351a809bba7635f205ee97904c2cf4e1f123111df6138182fa1. AI-assisted: yes.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T02:38:12Z.
Darkest Dungeon II (
PPSA19591) now reaches its narrated opening on a private integration of this PR with maina6dcea9279b53b3a39c13695eac66f7c8b5b503c, tested heada6383f401ea2aaf4e6d90905510ad30c957cd864using PR headb1eb0dd1eba18aeeabf15bfed8e081eb8af78a0a.The baseline debugger maps the null argument read to
NativePluginPS5Example.prx.guest.prx, file offset0x423a. With deferred initialization, the first native run reaches the readable confirmation screen; a second run with controller inputs passes that screen and renders the illustrated opening with readable subtitles. Both runs exit 0 after ordinary window-close requests, with the temporary kernel memory limit restored. Gameplay and performance are unverified.At the stated private integration: the full runtime built, 238/238 relinker tests passed, and the real-kernel lifecycle test passed its never-start, start, zero-start, concurrent, reentrant and reload modes. The concurrent case does not establish that the second thread reached the loader before the initializer was released, so it is not a complete waiter-timing test. No Windows/macOS or sanitizer result is claimed.
Evidence: reports, focused test logs, mapped baseline fault, tested patch and screenshots, SHA-256
e2da36750e8ea38c3d027e10bf3133fcf427b6e74c062b08ccd6fd8bbd9c9764.The public branch is unchanged and this remains draft pending initialization-timing review. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T03:07:25Z.
Pushed
624609bfe2e3bbf58e0a66f1e46349158e39d661to strengthen the concurrent lifecycle regression. The first initializer now stays blocked until the second loader thread enterspthread_cond_wait; the test also requires that wait to return. This addresses the timing gap noted in my previous report. The wrapper is confined to the Linux test executable; production loader code is unchanged.All six lifecycle modes pass with the fixture compiled from this public branch, against the previously full-built private integration
a6383f401ea2aaf4e6d90905510ad30c957cd864(maina6dcea9279plus PR headb1eb0dd1eb). ItsDynamicLoader.cppis identical to the public branch. Conventions and whitespace checks pass. This is not a full rebuild of the new public head.A further native Darkest Dungeon II (
PPSA19591) run on that same pinned integration passed the narration and prologue selection, rendered the stagecoach scene, and reached the party tutorial. It exited 0 after the scheduled ordinary window close at 571 seconds; the temporary kernel limit was restored to 64 MiB. The attached 300/450/550-second screenshots show those scenes. Combat, overall rendering correctness and performance remain unverified.Reports, test log and patch, native supervisor log and screenshots, SHA-256
3bfa3c0f62f8257ef7dd6980c52077b16442c182c4f426954f1abbfd1c3d0b80.Still draft pending initialization-timing review. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T03:39:59Z.
Marked ready for review at unchanged head
624609bfe2e3bbf58e0a66f1e46349158e39d661.The maintainer decision on #8162 accepts uniform Windows deferral with documented limitations. That is related design precedent for this Linux implementation; it does not establish console module-start ordering or repeated-load result semantics. Those limitations remain documented. The deterministic concurrent waiter regression and pinned Darkest Dungeon II party-tutorial evidence are in the description and preceding report.
Could a maintainer dispatch the full Linux/Windows build for this PR? Current automatic PR runs cover the relinker and ASan; full runtime jobs require main or manual dispatch. Marking ready alone does not start those jobs. No new test result or performance claim is implied. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T08:44:20Z.
Refreshed to
fa3e35112131790755dcddadc54cf2c7b8dea37e: fourteen topic commits cleanly rebased onto maind6eafa54, without merge commits. The relinker and all runtime libraries build from this head. All 239 relinker tests and the real-kernel lifecycle wrapper (six modes, including the deterministic concurrent waiter) pass, with no skips or failures. Conventions and whitespace checks pass.The branch also merges cleanly with newer main
7e2ba73e, and conventions pass against it; build/test evidence remains pinned tod6eafa54. No new title, GPU, performance or Windows/macOS runtime result is claimed. The complete runtime suite was not run.Patch, range-diff, build/test logs, JUnit and independent verification, SHA-256
fcf647f928390b33f0fa21374c136d3ed72f8236687078e80a2d376fdd1cb1cd. Description updated. Maintainer-dispatched full cross-platform CI remains useful. AI-assisted: yes.