facebookarchive/profilo

Crash on API level 28 when SoLoader initialise the .so libraries

prithvibhola opened this issue · 6 comments

Hi, we are facing an issue on API Level 28 while Profilo tries to load .so Libraries using SoLoader. Here are the stack traces

E/SoLoader: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.app.telemetry/lib-main/libgnustl_shared.so" has unexpected e_machine: 40 (EM_ARM)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err: com.facebook.soloader.SoLoader$WrongAbiError: APK was built for a different platform
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:645)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:587)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.DirectorySoSource.loadDependencies(DirectorySoSource.java:111)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:71)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.UnpackingSoSource.loadLibrary(UnpackingSoSource.java:458)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:731)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:639)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:587)
2020-01-16 12:46:39.294 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.DirectorySoSource.loadDependencies(DirectorySoSource.java:111)
2020-01-16 12:46:39.295 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:71)
2020-01-16 12:46:39.295 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.UnpackingSoSource.loadLibrary(UnpackingSoSource.java:458)
2020-01-16 12:46:39.295 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:731)
2020-01-16 12:46:39.295 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:639)
2020-01-16 12:46:39.295 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:577)
2020-01-16 12:46:39.295 26366-26366/com.app.telemetry W/System.err:     at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:525)
2020-01-16 12:46:39.295 26366-26366/com.app.telemetry W/System.err:     at com.facebook.profilo.logger.Logger.initialize(Logger.java:58)
2020-01-16 12:46:39.296 26366-26366/com.app.telemetry W/System.err:     at com.facebook.profilo.core.TraceOrchestrator.bind(TraceOrchestrator.java:230)
2020-01-16 12:46:39.296 26366-26366/com.app.telemetry W/System.err:     at com.facebook.profilo.core.TraceOrchestrator.initialize(TraceOrchestrator.java:101)

and

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libprofilo.so caused by: couldn't find DSO to load: libprofilo_fmt.so caused by: APK was built for a different platform
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:789)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:639)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:577)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:525)
        at com.facebook.profilo.logger.Logger.initialize(Logger.java:58)
        at com.facebook.profilo.core.TraceOrchestrator.bind(TraceOrchestrator.java:230)
        at com.facebook.profilo.core.TraceOrchestrator.initialize(TraceOrchestrator.java:101)

Specifications of the emulator on which we are getting the issue:
Android version: 28
Device: Pixel XL
Architecture: x86,armeabi-v7a,armeabi(executing adb -s emulator-5556 shell getprop ro.product.cpu.abilist)

We backtracked the releases and figured out that the issue is coming from the following release : https://github.com/facebookincubator/profilo/tree/release-62ca671 in which the SoLoader is updated to the latest version(0.8.0)

Is this a known issue or are we missing something?

Hey, @prithvibhola !

Thanks for bringing this up. It looks like this is a legit issue and we're actively working on it. We're very sorry for this, but we'll try to fix this ASAP =)

In the meantime, I have a quick question. Is this app running on arm64?

Hey, we tested the application on the emulator with 32-bit architecture.

This looks the same as SoLoader issue #55.
I've investigated this a bit and I am reasonably convinced that particular emulator image is just broken.

The Google APIs version is reporting both x86 and armv7 compatibility when the non-Google version correctly only reports x86. As a workaround, can you try using an SDK 29 (Q) Google APIs image? In my testing, that image should behave better.

I've also posted this on the Android bug tracker here.

Hey @BurntBrunch ,
If this is the Google APIs version issue, then why the issue is coming on the latest version of SoLoader and working fine with v0.6.1?

@prithvibhola, unfortunately, I found out that downgrade to 0.6.1 didn't help as I faced crashes on production :/ facebook/SoLoader#55

then why the issue is coming on the latest version of SoLoader and working fine with v0.6.1?

0.8.0 fixes bugs in 0.6.1 around phones that report the wrong ABIs.
Google are reporting that the image is actually correct because there's runtime dynamic code translation in that image. I'll try and find a way to fix this in the soloader repo, moving discussions there.