Fix JvmtiAgent native library load when extractNativeLibs=false#210
Open
jselbo wants to merge 1 commit intolinkedin:mainfrom
Open
Fix JvmtiAgent native library load when extractNativeLibs=false#210jselbo wants to merge 1 commit intolinkedin:mainfrom
jselbo wants to merge 1 commit intolinkedin:mainfrom
Conversation
Debug.attachJvmtiAgent with a bare library name fails when extractNativeLibs=false (the AGP default for minSdk >= 23) because the .so is stored inside the APK rather than extracted to disk. The JVMTI agent loading path in ART uses OpenNativeLibrary with filesystem-only search paths, unlike System.loadLibrary which can load directly from APK via the linker namespace. Resolve the library path via BaseDexClassLoader.findLibrary() first. If the resolved path contains '=' (common in base64-encoded app install directories), copy the library to a temp file since Debug.attachJvmtiAgent rejects paths with '='. If findLibrary returns null, extract the library from classloader resources to a temp file.
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.
Fixes #164
Debug.attachJvmtiAgentwith a bare library name fails whenextractNativeLibs=false(the AGP default for minSdk >= 23) because the .so is stored inside the APK rather than extracted to disk. The JVMTI agent loading path in ART usesOpenNativeLibrarywith filesystem-only search paths, unlikeSystem.loadLibrarywhich can load directly from APK via the linker namespace. This seems like a bug in the Android jvmti agent code.Resolve the library path via
BaseDexClassLoader.findLibrary()first. If the resolved path contains '=' (common in base64-encoded app install directories), copy the library to a temp file since Debug.attachJvmtiAgent rejects paths with '='. If findLibrary returns null, extract the library from classloader resources to a temp file.To verify this, I configured a test app with minSdk >= 23 and without
android:extractNativeLibs=true. With this fix, the agent now attaches and the mock maker works as expected.