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

java.lang.UnsatisfiedLinkError couldn't find DSO to load: libimagepipeline.so #2076

Closed
jyh149129 opened this issue Mar 23, 2018 · 9 comments
Closed

Comments

@jyh149129
Copy link

Info:

  • Fresco version:1.8.1
  • Platform version: Vivo Android 5.1.1, CPU: arm64-v8a

couldn't find DSO to load: libimagepipeline.so
com.facebook.soloader.SoLoader.void doLoadLibraryBySoName(java.lang.String,int,android.os.StrictMode$ThreadPolicy)...
03-23 19:21:55.955 17814 17931 E art : dlopen("/data/data/xxx/lib-main/libimagepipeline.so", RTLD_LAZY) failed: dlopen failed: "/data/data/xxx/lib-main/libimagepipeline.so" is 64-bit instead of 32-bit
03-23 19:21:55.955 17814 17931 E SoLoader: Could not load: libimagepipeline.so

detail

com.facebook.soloader.SoLoader.void doLoadLibraryBySoName(java.lang.String,int,android.os.StrictMode$ThreadPolicy)(SoLoader.java:522)
com.facebook.soloader.SoLoader.void loadLibraryBySoName(java.lang.String,java.lang.String,java.lang.String,int,android.os.StrictMode$ThreadPolicy)(SoLoader.java:420)
com.facebook.soloader.SoLoader.void loadLibrary(java.lang.String,int)(SoLoader.java:370)
com.facebook.soloader.SoLoader.void loadLibrary(java.lang.String)(SoLoader.java:335)
com.facebook.imagepipeline.nativecode.ImagePipelineNativeLoader.void load()(ImagePipelineNativeLoader.java:42)
com.facebook.imagepipeline.memory.NativeMemoryChunk.void ()(NativeMemoryChunk.java:33)
com.facebook.imagepipeline.memory.NativeMemoryChunkPool.com.facebook.imagepipeline.memory.NativeMemoryChunk alloc(int)(NativeMemoryChunkPool.java:58)
com.facebook.imagepipeline.memory.NativeMemoryChunkPool.void free(java.lang.Object)(NativeMemoryChunkPool.java:20)
##parent##1##parent##
##child## java.lang.Object alloc(int)##child##
com.facebook.imagepipeline.memory.BasePool.java.lang.Object get(int)(BasePool.java:257)
com.facebook.imagepipeline.memory.NativePooledByteBufferOutputStream.void (com.facebook.imagepipeline.memory.NativeMemoryChunkPool,int)(NativePooledByteBufferOutputStream.java:51)
com.facebook.imagepipeline.memory.NativePooledByteBufferFactory.com.facebook.imagepipeline.memory.NativePooledByteBuffer newByteBuffer(java.io.InputStream,int)(NativePooledByteBufferFactory.java:98)
com.facebook.imagepipeline.memory.NativePooledByteBufferFactory.com.facebook.common.memory.PooledByteBufferOutputStream newOutputStream(int)(NativePooledByteBufferFactory.java:26)
##parent##4##parent##
##child## com.facebook.common.memory.PooledByteBufferOutputStream newOutputStream()##child##
##child## com.facebook.common.memory.PooledByteBuffer newByteBuffer(java.io.InputStream,int)##child##
##child## com.facebook.common.memory.PooledByteBuffer newByteBuffer(byte[])##child##
##child## com.facebook.common.memory.PooledByteBuffer newByteBuffer(java.io.InputStream)##child##
com.facebook.imagepipeline.producers.LocalFetchProducer.com.facebook.imagepipeline.image.EncodedImage getByteBufferBackedEncodedImage(java.io.InputStream,int)(LocalFetchProducer.java:89)
##parent##2##parent##
##child## com.facebook.imagepipeline.image.EncodedImage getEncodedImage(com.facebook.imagepipeline.request.ImageRequest)##child##
##child## java.lang.String getProducerName()##child##
com.facebook.imagepipeline.producers.LocalFetchProducer.com.facebook.imagepipeline.image.EncodedImage getEncodedImage(java.io.InputStream,int)(LocalFetchProducer.java:101)
com.facebook.imagepipeline.producers.LocalFileFetchProducer.com.facebook.imagepipeline.image.EncodedImage getEncodedImage(com.facebook.imagepipeline.request.ImageRequest)(LocalFileFetchProducer.java:34)
com.facebook.imagepipeline.producers.LocalFetchProducer$1.com.facebook.imagepipeline.image.EncodedImage getResult()(LocalFetchProducer.java:54)
com.facebook.imagepipeline.producers.LocalFetchProducer$1.java.lang.Object getResult()(LocalFetchProducer.java:50)
com.facebook.common.executors.StatefulRunnable.void run()(StatefulRunnable.java:45)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
com.facebook.imagepipeline.core.PriorityThreadFactory$1.void run()(PriorityThreadFactory.java:53)
java.lang.Thread.run(Thread.java:818)

@gengjiawen
Copy link
Contributor

Possibly duplicate of #2049.

@lambdapioneer
Copy link
Contributor

Yes, this seems to be a duplicate of #2049 (especially #2049 (comment)). @jyh149129, I'm closing the issue here to focus the discussion there :)

Thanks @gengjiawen!

@StoneBang
Copy link

fuck the react

@hardapps1692
Copy link

Where is the solution? I am facing issue in 1.13.0 version of Fresco dependency. Please help me out.

@artemisia
Copy link

I think I found why this bug happened, because the cpu_abi of /data/data/yourpackage/lib and /data/data/yourpackage/lib-main is different.
And why is it different? because ExtractFromZipSoSource.ensureDsos() had a defect.
What defect? There was an assumption that Android OS think you were a 64-bit app when you had both 32-bit and 64-bit so libraries. But, the rule was broken on the OPPO R7sm (Android 5.1.1 ColorOS: V3.0_170510_beta).

I have fixed the bug on my OPPO by modifying code, I will make a pull request later, expecting to help your guys.

@oprisnik
Copy link
Contributor

Awesome, thanks for investigating @artemisia!

@sususweet
Copy link

@artemisia Wish to see your PR!This bug confuses me a lot...

@YS-WEI
Copy link

YS-WEI commented Jul 18, 2019

Sorry, my english is bad.

Device: Mobile Device: OPPC R7sm (AndroLinkid 5.1.1)
Findings:
When exists armeabi-v7a nad arm64-v8a in apk, generally loaded arm64-v8a. But OPPO R7sm is loaded armeabi-v7a.

I check path data/app//lib/. Find is arm, is not arm64. Generally should be arm64

When init soloader, will unzip data/app//*.apk. And copy .so to data/data//lib-main.
This flow will check the device support abi(ZipUnpacker.ensureDsos() on ExtractFromZipSoSource.java),
and check data/app//lib/arm/
.so and */.so of apk file (ApkUnpacker.shouldExtract() on ApkSoSource.java).
The files is not same. will copy to data/data//lib-main.

The get supportedAbis is ["arm64-v8a", "armeabi-v7a", "armeabi"]. Confirm the *.so file sequentially.
But data/app//lib/ is arm on OPPC R7sm, so always copy arm64-v8a the os file to data/data//lib-main.

Lead to *.so is 64-bit instead of 32-bit issue.

My solution:

Modify SoLoader library. Add check data/app//lib/ is arm or arm64.

File:
ExtractFromZipSoSource.java

    ...
    final ZipDso[] ensureDsos() {
      if (mDsos == null) {
        Set<String> librariesAbiSet = new LinkedHashSet<>();
        HashMap<String, ZipDso> providedLibraries = new HashMap<>();
        Pattern zipSearchPattern = Pattern.compile(mZipSearchPattern);
        String[] supportedAbis = SysUtil.getSupportedAbis();
        Enumeration<? extends ZipEntry> entries = mZipFile.entries();

+        // Fixed couldn't find DSO to load:  "xxx.os"  is 64-bit instead of 32-bit
+       File sysLibPath =  new File(mContext.getApplicationInfo().nativeLibraryDir);
+       String sysLibAbi = sysLibPath.getPath().substring(sysLibPath.getPath().lastIndexOf("/")+1);
+       if(sysLibAbi.equalsIgnoreCase("arm")) {
+         // sys lib is load armeabi-v7a, this exception case
+         ArrayList<String> newSupportedAbis = new ArrayList();
+         for(String abi : supportedAbis) {
+           if(abi.equalsIgnoreCase("arm64-v8a")) {
+               //skip arm64-v8a
+               continue;
+           }
+
+           newSupportedAbis.add(abi);
+         }
+
+         supportedAbis = newSupportedAbis.toArray(new String[newSupportedAbis.size()]);
+       }


        while (entries.hasMoreElements()) {
          ZipEntry entry = entries.nextElement();
          Matcher m = zipSearchPattern.matcher(entry.getName());
    ...

@spvalencia
Copy link

fuck the react

Welcome Flutter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants