Repository navigation
fix(libkernel): bind deferred initialization to the loaded image - #4419
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On Windows, a deferred guest module reloaded at the same base address returns a valid load handle without running its entry or constructors.
InitializeDeferredModulekeeps a process-wide set of native base addresses after the images have been unloaded. It also marks an image initialized before its entry has finished, so another thread can return from a load while initialization is still blocked.Keep the state in the mapped initialization table. Completion consumes its entry/count header; Windows restores the original file-backed table on the next actual load. An image retained by another guest or native reference stays initialized. A different thread waits for completion, and recursive loading by the initializing thread retains its existing behavior. The loader restores the metadata page protection and wakes waiters when initialization ends. An initialization exception marks the current image failed until it is unloaded.
The existing table layout and initializer pointer slots are preserved. Document the mapped state in Architecture and add Windows regression fixtures for reload, native pinning, concurrent initialization and recursive loading.
Tested
Windows x86-64, Release, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; real libkernel/libc APIs and a module produced by the relinker.
--windows --module-dirpassed reload and external-pin cases with the unchanged metadata format.Linux/macOS runtime, initializer exception propagation and a PS5 title were not exercised locally. The production change is inside the Windows deferred-loader path.
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)