Swordfish90 / LibretroDroid

GNU General Public License v3.0
75 stars 17 forks source link

Loading game via bytes (not path) broken; segfaults #77

Closed tytydraco closed 3 years ago

tytydraco commented 3 years ago

This issue seems to be relatively new with these new alpha commits. I'll do some testing, but I want to make an official report first.

Reproduce

1) Instead of specifying a game path, specify a game as bytes 2) Launch the build and observe the crash

tytydraco commented 3 years ago

Dumped the stacktrace with ndk-stack; just keeping this thread updated

Build fingerprint: 'xiaomi/tissot/tissot_sprout:8.0.0/OPR1.170623.026/8.1.10:user/release-keys'
#00 0x000000000007e208 /apex/com.android.runtime/lib64/bionic/libc.so (__memcpy+248) (BuildId: 17db0765cecb9258845d33f214014b33)
#01 0x00000000003ccfac /apex/com.android.runtime/lib64/libart.so (art::JNI::GetByteArrayRegion(_JNIEnv*, _jbyteArray*, int, int, signed char*)+796) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#02 0x0000000000370184 /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::CheckJNI::GetPrimitiveArrayRegion(char const*, art::Primitive::Type, _JNIEnv*, _jarray*, int, int, void*)+960) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#03 0x0000000000073730 /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/lib/arm64/liblibretrodroid.so (_JNIEnv::GetByteArrayRegion(_jbyteArray*, int, int, signed char*)+64) (BuildId: 377fe0920d4d9a08592b3ffa5f0da0957d8da430)
                                                                                                            _JNIEnv::GetByteArrayRegion(_jbyteArray*, int, int, signed char*)
                                                                                                            /home/tytydraco/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/jni.h:930:7
#04 0x0000000000073620 /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/lib/arm64/liblibretrodroid.so (Java_com_swordfish_libretrodroid_LibretroDroid_loadGameFromBytes+112) (BuildId: 377fe0920d4d9a08592b3ffa5f0da0957d8da430)
                                                                                                            Java_com_swordfish_libretrodroid_LibretroDroid_loadGameFromBytes
                                                                                                            /home/tytydraco/Documents/Projects/LibretroDroid/libretrodroid/src/main/cpp/libretrodroidjni.cpp:375:14
#05 0x000000000013f350 /apex/com.android.runtime/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#06 0x00000000001365b8 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#07 0x000000000014508c /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+276) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#08 0x00000000002df0d4 /apex/com.android.runtime/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+384) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#09 0x00000000002da3b4 /apex/com.android.runtime/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#10 0x000000000059abcc /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+368) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#11 0x0000000000130994 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#12 0x0000000000002c0a [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView$initializeCore$1.invoke+114)
#13 0x0000000000598330 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1432) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#14 0x0000000000130814 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#15 0x0000000000002b5c [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView$initializeCore$1.invoke)
#16 0x0000000000599b24 /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1740) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#17 0x0000000000130a14 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#18 0x00000000000039dc [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView.catchExceptions+12)
#19 0x000000000059a6c0 /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+1168) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#20 0x0000000000130914 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#21 0x0000000000003a7a [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView.initializeCore+14)
#22 0x000000000059a6c0 /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+1168) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#23 0x0000000000130914 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#24 0x0000000000003958 [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView.access$initializeCore)
#25 0x000000000059aecc /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+1136) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#26 0x0000000000130994 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#27 0x00000000000029de [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView$Renderer$onSurfaceCreated$1.invoke+22)
#28 0x0000000000598330 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1432) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#29 0x0000000000130814 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#30 0x000000000000298c [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView$Renderer$onSurfaceCreated$1.invoke)
#31 0x0000000000599b24 /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1740) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#32 0x0000000000130a14 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#33 0x00000000000039dc [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView.catchExceptions+12)
#34 0x000000000059a6c0 /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+1168) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#35 0x0000000000130914 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#36 0x0000000000003940 [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView.access$catchExceptions)
#37 0x000000000059aecc /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+1136) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#38 0x0000000000130994 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#39 0x0000000000002aca [anon:dalvik-classes3.dex extracted in memory from /data/app/com.android.gl2jni-JV8KUSX1WNy0J-98U9_OGQ==/base.apk!classes3.dex] (com.swordfish.libretrodroid.GLRetroView$Renderer.onSurfaceCreated+42)
#40 0x0000000000599b24 /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1740) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#41 0x0000000000130a14 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#42 0x00000000002c89f4 /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.guardedRun+912)
#43 0x000000000059a6c0 /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+1168) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#44 0x0000000000130914 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#45 0x00000000002c9068 /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.run+48)
#46 0x00000000002afd20 /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.16952165292066557704+240) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#47 0x0000000000589668 /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1012) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#48 0x000000000013f468 /apex/com.android.runtime/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
#49 0x0000000000136334 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 305e71e8e3ac3377f1ac1cc192146d00)
tytydraco commented 3 years ago

Fixed in https://github.com/Swordfish90/LibretroDroid/pull/78

Gotta say, I hate JNI :laughing: I wish this could be written in Kotlin. But obviously that can't happen. Anyway, I finally figured out why Ludere kept exploding when I tried to merge these changes! Honestly proud of myself a little.

Swordfish90 commented 3 years ago

Yeah, sadly debugging in jni is quite painful. Thank you for taking a look into this and spotting the issue! Great job!