1

How to get crash dump when my app crashes, it usually happens in c++ module of my apk. I found that this code in c++

try 
{
 made some crash code to test
}
catch(...)
{
 i ,catch it ,and write the info to the sd card.
}

when crash happens, the code do not enter the catch part, it crashed immediately.

Is there anything wrong? Thanks.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
ddr
  • 33
  • 7

1 Answers1

1

Your crash is because of segmentation fault.

SIGSEGV crash is not caught by the try catch. SIGSEGV in C++ is considered bug and some thing needs to be done with the code to fix that rather than wrap it with try catch.

If it is very necessary for you to catch the seg fault, you may have a look at this post. You may try it, but there is no guarantee that it will work though.

Community
  • 1
  • 1
Krypton
  • 3,337
  • 5
  • 32
  • 52
  • yeah,i read the post, but when the crash happens, i do not know where to place my function(the code in url) to get sigsegv info. because there is no call-back function when the crash happens.or there is but i do not find? – ddr Mar 28 '13 at 03:39
  • You do it in the CATCH block, like the author guide: TRY { // write code here } CATCH { // write code here ex.WriteMsg(); cout << "signal number = " << ex.getSignal() << endl; } – Krypton Mar 28 '13 at 03:48
  • yeah , but when catch happens in try block, it did not enter catch block. the apk just quit .. . – ddr Mar 28 '13 at 03:55
  • So I may guess that the technique doesn't work on Android. Check [How can I catch SIGSEGV (segmentation fault) and get a stack trace under JNI on Android?](http://stackoverflow.com/a/1789879/950983) – Krypton Mar 28 '13 at 04:21
  • i got the post you give me(http://stackoverflow.com/questions/1083154/how-can-i-catch-sigsegv-segmentation-fault-and-get-a-stack-trace-under-jni-on/1789879#1789879) ,i will try it .thank you – ddr Mar 28 '13 at 12:55
  • anything is ok, but one more thing, i find the log in logcat,there is no logs like this: 03-18 12:07:00.490: I/DEBUG(21702): pid: 22914, tid: 22957 >>> com.xxx.yyyyo <<< 03-18 12:07:00.490: I/DEBUG(21702): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 3c3c3c3c. can you tell me why? thanks.:) – ddr Mar 31 '13 at 18:03