Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed #18

Closed
fanjavaid opened this issue Jun 16, 2023 · 11 comments
Closed

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed #18

fanjavaid opened this issue Jun 16, 2023 · 11 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@fanjavaid
Copy link

Hello, I implemented the library version 6.0.0 and I got the following crashes:

  • Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/user/0/com.gbox.android/_root/data/internal_app/com.company.android-gep493u9x7yrZ9yoy5Lqtw==/lib/arm/libpolarssl.so" is 32-bit instead of 64-bit at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.aheaditec.talsec.security.z1.<clinit>(SourceFile:1) at com.aheaditec.talsec.security.y1.<init>(SourceFile:5) at com.aheaditec.talsec.security.y1.a(SourceFile:4) at com.aheaditec.talsec_security.security.api.Talsec.start(SourceFile:1)

  • Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "libpolarssl.so" not found

When I check my universal APK, I have the libpolarssl.so both in x86 and x64. However I distribute the app as Bundle in the Google Play Console.

I had tried to add exception handler when called at com.aheaditec.talsec_security.security.api.Talsec.start but the crash still exist.

Is the Library for android support for x86? And any insight why the crash happens?

Thank you

@msikyna
Copy link
Member

msikyna commented Jun 21, 2023

Hello @fanjavaid,

The library should support both x86 and x64. The library (aar) contains libpolarssl.so for all ABIs (x86, x86_64, armeabi-v7a, arm64-v8a). Can you check on which devices the crash occurs? Is it a general problem for all x64 devices, or it only occurs on some devices? You can also inspect your bundle file (.aab) if the base/lib directory contains libpolarssl.so for all ABIs. We will try to look into this issue but I’m not sure if we will be able to reproduce this issue.

Best regards,
Talsec Team

@fanjavaid
Copy link
Author

fanjavaid commented Jun 22, 2023

Hello @msikyna

Here is the details about the devices:

Screenshot 2023-06-22 at 10 52 55 Screenshot 2023-06-22 at 10 52 47

Well, the Bundle file contains for all ABIS : x86_64, x86, arm64-v8a, armeabi-v7a.

🔴  Oh, in my exception above (my question) it is trying to lookup in the arm directory & yes it is not available in my Bundle file.

Or do you have any suggestion how to handle it? I believe App crashes when invoke Talsec.start(), but I can't catch the Exception. Crash still exists.

Thank you

@rpavliuk
Copy link

We have, I guess, a similar issue:

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.signnow.android-9yrhDsO0RpoyrWxEyG4MXA==/base.apk"],nativeLibraryDirectories=[/data/app/com.signnow.android-9yrhDsO0RpoyrWxEyG4MXA==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libpolarssl.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1011) at java.lang.System.loadLibrary(System.java:1657) at com.aheaditec.talsec.security.b2.<clinit>(SourceFile:1) at com.aheaditec.talsec.security.a2.<init>(SourceFile:6) at com.aheaditec.talsec.security.a2.a(SourceFile:4) at com.aheaditec.talsec_security.security.api.Talsec.start(SourceFile:1) at com.signnow.app.app.SignNowApp.setTalsecLibrary(SignNowApp.kt:128) at com.signnow.app.app.SignNowApp.onCreate(SignNowApp.kt:64) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740) at android.app.ActivityThread.-wrap1() at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

It is our first release with your library. At this time it occurred only on Nexus 5X devices. I have researched SO a bit and found a similar issue. I don't want to try the solution on my current users. Can you provide some information about this error?
Or maybe I can safely use this solution?

Also, I need to mention that I have this block in my build.gradle file. Because I have some native libraries:

ndk {
            abiFilters.addAll(
                listOf(
                    "arm64-v8a", "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
                )
            )
        }

@msikyna
Copy link
Member

msikyna commented Jul 26, 2023

Hello @fanjavaid , @rpavliuk ,

we are looking at the issue. Thank you for details.

Kind regards,
Talsec team

@msikyna msikyna added the bug Something isn't working label Jul 26, 2023
@rpavliuk
Copy link

rpavliuk commented Aug 7, 2023

@msikyna Can we help you with framing this bug?

@xprikryl2
Copy link
Member

Hello @fanjavaid,

We've managed to provide a partial solution. The native library libpolarssl.so is no longer required in the freeRASP workflow, so the bug mentioned above shouldn't occur anymore.

Nevertheless, there are still other native libraries that are crucial for freeRASP (libsecurity.so and libclib.so) that can also be problematic. I found a lot of open issues regarding this problem (eg. Xiaomi native library load, App bundle UnsatisfiedLinkError, App Bundle native crash, and many others). It looks like there are still some issues during native library loading.

I also stumbled upon two proposed solutions, but I haven't had the possibility to test them out yet.

  1. Disabling bundle ABI split in the build.gradle as described here. This will slightly increase the size of a bundle.
bundle {
    abi {
        // This property is set to true by default.
        enableSplit = false
    }
}
  1. In the stack trace of this issue above, the application is trying to load a native library from the app directory in the filesystem. That usually means that the native libraries are compressed and extracted to the filesystem during the installation. You can try to modify your extractNativeLibs and If you’re using App Bundle, also set android.bundle.enableUncompressedNativeLibs=true along with the extractNativeLibs configuration option.
  2. There is also a GH project ReLinker that tries to solve issues with native libraries linking.

If you manage to try one of the proposed solutions above or if you find a new one, please share your findings with us.

Best regards,
Talsec Team

@rpavliuk
Copy link

rpavliuk commented Aug 7, 2023

Thank you so much, we will try to update your library and discuss the suggested solutions.
I will update you after the release of our app

@rpavliuk
Copy link

rpavliuk commented Aug 28, 2023

We have tried to update the library to the latest version, but this exception still occurs:

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.signnow.android-tvn2uhQIOfml5bFibF2NLQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.signnow.android-tvn2uhQIOfml5bFibF2NLQ==/lib/arm64, /system/lib64, /system/product/lib64]]] couldn't find "libsecurity.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1067) at java.lang.Runtime.loadLibrary0(Runtime.java:1007) at java.lang.System.loadLibrary(System.java:1667) at com.aheaditec.talsec.security.a2.<clinit>(SourceFile:1) at com.aheaditec.talsec.security.z1.<init>(SourceFile:6) at com.aheaditec.talsec.security.z1.a(SourceFile:4) at com.aheaditec.talsec_security.security.api.Talsec.start(SourceFile:4) at com.signnow.app.app.SignNowApp.setTalsecLibrary(SignNowApp.kt:129) at com.signnow.app.app.SignNowApp.onCreate(SignNowApp.kt:64) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460) at android.app.ActivityThread.access$1300(ActivityThread.java:219) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

But I want to notice that this crash occurs on the device Mainline brand Google. So, this can be an emulator, in this case, it's not an issue for us.
Also, we will check the recommensations from the message above, maybe we can use it in our project.
We will monitor this crash and update you if we will find something interesting.

Thanks!

@msikyna msikyna added documentation Improvements or additions to documentation and removed waiting for response Response from reporter is needed labels Aug 29, 2023
@rpavliuk
Copy link

rpavliuk commented Sep 8, 2023

@msikyna After monitoring this crash for some time we can conclude that it happens more on Emulators or already Rooted devices. So, it is not affecting us, because we plan to block these devices anyway.
But after the update we have encountered a new crash. I have created a separate issue for it.

@fanjavaid
Copy link
Author

Hello, after releasing the updated version with workarounds above, the issue about UnsatisfiedLinkError was not happening. But, like @rpavliuk there is a new issue: Fatal Exception: java.lang.RuntimeException: Package manager has died in the latest Talsec version.

@msikyna
Copy link
Member

msikyna commented Sep 15, 2023

Hello @rpavliuk , @fanjavaid ,
thank you for reporting the issue! We are looking into it.

Kind regards,
Talsec team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants