0

I'm writing an Android app that uses huge amounts of JNI-c code (mostly ported from other project). My problem is that my app crashes occasionally. And I've got no way to find out where is the crashing point unless I attach gdb. Sadly, I can not attach gdb all the time. And in this case, I got no clew on some crashes because my app just dies silently.

What I want is to enable coredump in Android for my JNI-massive app. Or if there is any better idea to help out my trouble, I appreciate your ideas. Any pointers?

jaeyong
  • 8,951
  • 14
  • 50
  • 63
  • What thread does your code run in? If the ported code has not been written for multi-threaded execution, I would recommend making sure it is either executed from only one thread, or at least treating the native library as a shared resource (and protecting it with some kind of lock). – 18446744073709551615 Feb 16 '15 at 12:57
  • Do you have a stack trace of the crash point in your log? In this case, ndk-stack should help. – cmatsuoka Feb 16 '15 at 12:59
  • @cmatsuoka No, I don't have a stack trace for JNI code. What I want is such kind of stack trace for JNI code? Do you have a special option to enable such JNI stack trace? – jaeyong Feb 16 '15 at 13:22
  • @18446744073709551615 My ported code is running in multi-threaded execution. BTW, how come running in a single thread and locking could help my situation? – jaeyong Feb 16 '15 at 13:23
  • `adb logcat` usually gives some stack trace even when the native code crashes (not much, but more than nothing). – 18446744073709551615 Feb 16 '15 at 13:28
  • There is a high probability that the code borrowed from another project is not thread-safe. There are many scenarios leading to introduction of concurrency bugs. Running in a single thread ___or___ locking would prevent concurrency bugs from showing. And if the bug is intermittent, there's a chance that it is a concurrency bug. (Although it may be a bug related to allocation/freeing the resources. I would add logging to malloc/free routines.) – 18446744073709551615 Feb 16 '15 at 13:34
  • @jaeyong I don't enable anything special, but when my code segfaults it generates a stack trace (similar to [this one](http://stackoverflow.com/questions/4846080)) in logcat. It can be used as an input to ndk-stack to pinpoint the exact crash location. – cmatsuoka Feb 16 '15 at 15:18

0 Answers0