foobnix / LibreraReader

Book Reader for Android
http://librera.mobi
Other
2.92k stars 309 forks source link

dlopen with `libMuPDF` failure when bootup #1202

Closed d3m3vilurr closed 10 months ago

d3m3vilurr commented 10 months ago

yesterday I updated to newer version, and sorry I also forgot old version which i used before. after the updating, an app was crashed.

E/AndroidRuntime( 4282): FATAL EXCEPTION: main
E/AndroidRuntime( 4282): Process: com.foobnix.pro.pdf.reader, PID: 4282
E/AndroidRuntime( 4282): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__strncpy_chk2" referenced by "libMuPDF.so"...
E/AndroidRuntime( 4282):    at java.lang.Runtime.loadLibrary(Runtime.java:364)
E/AndroidRuntime( 4282):    at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime( 4282):    at com.foobnix.pdf.info.AppsConfig.<clinit>(AppsConfig.java:41)
E/AndroidRuntime( 4282):    at com.foobnix.LibreraApp.onCreate(LibreraApp.java:63)
E/AndroidRuntime( 4282):    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
E/AndroidRuntime( 4282):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
E/AndroidRuntime( 4282):    at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
E/AndroidRuntime( 4282):    at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
E/AndroidRuntime( 4282):    at android.app.ActivityThread.handleBindApplication(Native Method)
E/AndroidRuntime( 4282):    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime( 4282):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime( 4282):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 4282):    at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 4282):    at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 4282):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4282):    at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 4282):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 4282):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 4282):    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
E/AndroidRuntime( 4282):    at dalvik.system.NativeStart.main(Native Method)

this system is very old eink device (android 4.4.2) and I used fdroid version 8.9.58 (sorry i didn't check with latest version and I'm waiting release on the f-droid)

I also checked my libc.so of the system. it doesn't have __strncpy_chk2.

1|root@PAPER_PRO:/system/lib # busybox strings libc.so | grep strncpy
__strncpy_chk
strncpy
strncpy buffer overflow
root@PAPER_PRO:/system/lib #
d3m3vilurr commented 10 months ago

revert to 8.9.50, then problem is resolved. 8.9.58 has invalid build for old android but it already resolved on 3631c2370 which changed min android version. anyway it's too bad for old android ebooks :'(

another invest, this problem is totally related current ndk. I modified strncpy inline function of $NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/bits/fortify/string.h to call __builtin___strncpy_chk from calling __strncpy_chk2

after that, result of link_to_mupdf_1.23.7.sh was removed __strncpy_chk2 information. (and also i was modified jni/Application-19.mk but it wouldn't affect result)

foobnix commented 10 months ago

I think this problem may be in the new NDK 26.1.xxx previous build was made with 25.2 If you want, I can rebuild beta.librera.mobi with 25.2 to check the problem ?

foobnix commented 10 months ago

could you please install beta.librera.mobi, I have added minSdk 16 with NDK 26.1 let's check if it works or not

d3m3vilurr commented 10 months ago

it works well!

thank you a lot

foobnix commented 10 months ago

thank you for the feedback on the problem, I have made a new release with this important fix.