frostwire / frostwire-jlibtorrent

A swig Java interface for libtorrent by the makers of FrostWire. Develop libtorrent based apps with the joy of coding in Java.
http://www.frostwire.com
MIT License
444 stars 137 forks source link

Debugging libtorrent crash on Android #286

Closed elgatito closed 11 months ago

elgatito commented 11 months ago

Hello.

My question is not directly related to frostwire-jlibtorrent, but to libtorrent on Android in general.

I have an app, that uses libtorrent RC_1_1 branch and is compiling to different platforms. So I have same code, same libtorrent version, boost, Android NDK, everything is literally the same. The only different is that target architecture.

And uses are saying that on Android 11+, arm64, when they add a torrent - it exits with a signal. So, not on startup of libtorrent, but on torrent addition. And on android_arm devices - it works fine, as on other platforms.

So I have 2 questions: 1) Have you met such situations that libtorrent does not work on android_arm64 but works on android_arm? 2) If I have a device that can reproduce the issue, and libtorrent is compiled with Swig, how to debug this situation and get s stacktrace to the error root?

elgatito commented 11 months ago

I'm very un-familiar with Android development, so it is hard to debug such issues for me.

That is what I see with logcat:

2023-07-28 16:17:24.299  5518-5543  Kodi                    org.xbmc.kodi                        D  exiting due to SIG_DFL handler for signal 11, ucontext 0x7cbb80be20
2023-07-28 16:17:24.299  5518-5602  libc                    org.xbmc.kodi                        A  exiting due to SIG_DFL handler for signal 11, ucontext 0x7cbb80be20
2023-07-28 16:17:24.301  5518-5602  libc                    org.xbmc.kodi                        A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5602 (Thread-3), pid 5518 (org.xbmc.kodi)
2023-07-28 16:17:24.486  6276-6276  crash_dump64            pid-6276                             I  obtaining output fd from tombstoned, type: kDebuggerdTombstoneProto
2023-07-28 16:17:24.495   930-930   tombstoned              tombstoned                           I  received crash request for pid 5602
2023-07-28 16:17:24.496  6276-6276  crash_dump64            pid-6276                             I  performing dump of process 5518 (target tid = 5602)

2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  Build fingerprint: 'google/sunfish/sunfish:13/TQ3A.230705.001/10216780:user/release-keys'
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  Revision: 'MP1.0'
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  ABI: 'arm64'
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  Timestamp: 2023-07-28 16:17:24.512531511+0200
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  Process uptime: 37s
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  Cmdline: org.xbmc.kodi
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  pid: 5518, tid: 5602, name: Thread-3  >>> org.xbmc.kodi <<<
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  uid: 10337
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  Abort message: '2023-07-28 16:16:50.418 T:5595  critical <general>: [plugin.video.elementum] Unable to start binary: [Errno 13] Permission denied: '/data/user/0/org.xbmc.kodi/cache/apk/assets/files/plugin.video.elementum/bin/android_arm64/elementum''
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x0  0000000000000000  x1  00000000000015e2  x2  0000000000000006  x3  0000007cbb80bc60
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x4  651f71646b636d60  x5  651f71646b636d60  x6  651f71646b636d60  x7  7f7f7f7f7f7f7f7f
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x8  00000000000000f0  x9  0000007cdc726a00  x10 0000000000000001  x11 0000007cdc764de4
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x12 0000000000000018  x13 000021a0dacbe52e  x14 0011a74f4752aa6b  x15 000000001a89bb48
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x16 0000007cdc7c9d58  x17 0000007cdc7a6c70  x18 00000079258ca000  x19 000000000000158e
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x20 00000000000015e2  x21 00000000ffffffff  x22 0000007cbb80be48  x23 0000007cdc4736f8
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x24 0000000000000040  x25 0000007925c83000  x26 000000000000000b  x27 0000007cdc473318
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      x28 0000000000000000  x29 0000007cbb80bce0
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A      lr  0000007cdc756968  sp  0000007cbb80bc40  pc  0000007cdc756994  pst 0000000000000000
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A  backtrace:
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A    NOTE: Function names and BuildId information is missing for some frames due
                                                                                                      NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
                                                                                                      NOTE: found under the lib/ directory are readable.
                                                                                                      NOTE: On this device, run setenforce 0 to make the libraries readable.
                                                                                                      NOTE: Unreadable libraries:
                                                                                                      NOTE:   /data/data/org.xbmc.kodi/cache/apk/assets/files/plugin.video.elementum/bin/android_arm64/elementum.so
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A        #00 pc 0000000000051994  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: 4e07915368c859b1910c68c84a8de75f)
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A        #01 pc 0000000000002520  /apex/com.android.art/lib64/libsigchain.so (art::SignalChain::Handler(int, siginfo*, void*)+1172) (BuildId: d5ff66d01eb05cf124e6fe95ee64abfd)
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A        #02 pc 00000000000007e8  [vdso] (__kernel_rt_sigreturn+0)
2023-07-28 16:17:25.419  6276-6276  DEBUG                   crash_dump64                         A        #03 pc 00000000008b89c4  /data/data/org.xbmc.kodi/cache/apk/assets/files/plugin.video.elementum/bin/android_arm64/elementum.so
2023-07-28 16:17:25.448   930-930   tombstoned              tombstoned                           E  Tombstone written to: tombstone_25
2023-07-28 16:17:25.451  2020-6324  ActivityTaskManager     system_server                        W    Force finishing activity org.xbmc.kodi/.Main
gubatron commented 11 months ago

Have you met such situations that libtorrent does not work on android_arm64 but works on android_arm?

Not that I'm aware of, we get weird crashes, but not consistently from android_arm alone, we get them from all different platforms.

If I have a device that can reproduce the issue, and libtorrent is compiled with Swig, how to debug this situation and get s stacktrace to the error root?

Do you upload your native debug symbols with your app bundle/apk to Google Play? Screenshot 2023-07-28 at 11 32 32 AM

This way you should be able to get better stacktraces

elgatito commented 11 months ago

Thanks! Will try to follow your recommendations. Not so easy for a person who is far away from Android :)