Fix early LoadedApk class loader initialization - #115
Open
mumingluan wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It changes JNI_OnLoad-time and early app bootstrap class-loader behavior across OEM-specific initialization sequences, which warrants final human review and broader device/API validation.
Pull request overview
This PR hardens LSPatch’s early bootstrap/class-loader initialization path to avoid null dereferences and re-entrant initialization pitfalls on certain Android variants during AppComponentFactory loading.
Changes:
- Switch native loader-parent discovery to use the defining class loader of
LSPAppComponentFactoryStub(viajava.lang.Class#getClassLoader) instead of readingActivityThread.mBoundApplication.infoearly. - In Java bootstrap, derive the base class loader from
LSPAppComponentFactoryStub’s defining loader and recover an in-progress stubLoadedApkfromActivityThread.mPackageswhenAppBindData.infois still unpublished.
File summaries
| File | Description |
|---|---|
| patch-loader/src/main/jni/src/patch_loader.cpp | Uses the metaloader stub class’s defining class loader as the stable parent for the in-memory framework loader, avoiding early ActivityThread dereferences. |
| patch-loader/src/main/java/org/lsposed/lspatch/loader/LSPApplication.java | Avoids stubLoadedApk.getClassLoader() during early/re-entrant init; recovers the stub LoadedApk from mPackages when mBoundApplication.info is not yet available. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
ActivityThread.mBoundApplication.infowhile the app component factory is still being initializedLoadedApkfromActivityThread.mPackagesduring early re-entrant initializationValidation
git diff --check127.0.0.1:5557with a 3.0 GB APK: