KingsleyYau / google-breakpad

Automatically exported from code.google.com/p/google-breakpad
0 stars 0 forks source link

Android app dies after catching signal #568

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use breakpad in native lib
2. compile lib using android ndk
3. run the app and make crash (f.e. writing to NULL pointer)

What is the expected output? What do you see instead?

signal catched, write to log, the app continues to work.
the app dies after cathing signal.

What version of the product are you using? On what operating system?

Please provide any additional information below.

code:
#include "native_lib.h"

#include <stdio.h>

#include "client/linux/handler/exception_handler.h"
#include "client/linux/handler/minidump_descriptor.h"

#include <android/log.h>

void debug(const char *format, ... ) {
    va_list argptr;
    va_start(argptr, format);
    __android_log_vprint(ANDROID_LOG_ERROR, "NATIVE_LIB", format, argptr);
    va_end(argptr);
}

bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
                  void* context,
                  bool succeeded) {
  debug("Dump path: %s\n", descriptor.path());
  return succeeded;
}

JNIEXPORT jint JNICALL 
Java_name_antonsmirnov_android_app_clang_libnative_func(JNIEnv *env, jobject 
obj)
{
    debug("init breakpad");
    google_breakpad::MinidumpDescriptor descriptor(".");
    google_breakpad::ExceptionHandler eh(descriptor, NULL, DumpCallback, NULL, true, -1);

    {
        debug("testing crash\n");

        char *ptr = 0;
        *ptr = '!'; // ERROR HERE!
        debug("unreachable\n");

    }

    debug("finished\n");
}

log:
03-08 15:04:13.398: ERROR/NATIVE_LIB(2828): init breakpad
03-08 15:04:13.398: ERROR/NATIVE_LIB(2828): testing crash
03-08 15:04:13.468: ERROR/NATIVE_LIB(2828): Dump path: 
./5f6097b2-5feb-0723-3271a7ff-2a4fcadd.dmp
03-08 15:04:13.468: WARN/crash_handler(2828): Caught a crash, signum=11
03-08 15:04:13.478: ERROR/webcore(2828): Report WebCore crash to the 
ErrorReportUtils at:Sat Mar 08 15:04:13 GMT+05:00 2014
03-08 15:04:13.508: INFO/ActivityManager(544): Start proc 
com.android.browser.CrashReportService for service 
com.android.browser/.CrashReportService: pid=2926 uid=10004 gids={3003, 1015, 
1007, 1028}
03-08 15:04:13.628: DEBUG/ActivityThread(2926): setTargetHeapUtilization:0.50
03-08 15:04:13.628: DEBUG/ActivityThread(2926): setTargetHeapIdealFree:8388608
03-08 15:04:13.628: DEBUG/ActivityThread(2926): 
setTargetHeapConcurrentStart:2097152
03-08 15:04:13.658: DEBUG/ads-notify-fd5dfce4(2926): 打开的 app 是: 
com.android.browser
03-08 15:04:13.718: ERROR/CloudMetadataBackupTask(1804): [pushFile] 
pkg[@metadata] 
file[/data/data/com.miui.backup/files/cloud/local/backup/@metadata-8-0/@metadata
.apk] result[-16] retryTime[1]
03-08 15:04:13.718: DEBUG/ads-notify-fd5dfce4(2926): 通道进行初始化
03-08 15:04:13.728: DEBUG/ads-notify-fd5dfce4(2926): 通道进行初始化OK
03-08 15:04:13.738: DEBUG/PushService(1049): 2014-03-08 15:04:13,748 - 
[DEBUG::PushService] - onStart() with intent.Action = null
03-08 15:04:13.998: DEBUG/WifiStateMachine(544): ConnectedState{ what=131155 
when=-2ms arg1=1 }
03-08 15:04:13.998: DEBUG/WifiStateMachine(544): L2ConnectedState{ what=131155 
when=-2ms arg1=1 }
03-08 15:04:13.998: DEBUG/wpa_supplicant(796): wpa_s 0x405a2ec0 cmd SIGNAL_POLL
03-08 15:04:13.998: DEBUG/wpa_supplicant(796): nl80211: survey data missing!
03-08 15:04:14.559: INFO/ActivityManager(544): No longer want 
com.google.android.gms.ui (pid 2056): hidden #25
03-08 15:04:14.589: INFO/ActivityManager(544): Process 
name.antonsmirnov.android.app (pid 2828) has died.
03-08 15:04:14.589: INFO/WindowState(544): WIN DEATH: Window{42733e18 
name.antonsmirnov.android.app/name.antonsmirnov.android.app.ui.MainActivity 
paused=false}
03-08 15:04:14.589: WARN/ActivityManager(544): Force removing 
ActivityRecord{435990a8 name.antonsmirnov.android.app/.ui.MainActivity}: app 
died, no saved state

Original issue reported on code.google.com by d...@antonsmirnov.name on 8 Mar 2014 at 9:09

GoogleCodeExporter commented 9 years ago
This is the default signal handler exiting your app. If you expect to recover 
and continue you'll need to add your own signal handler that does recovery. 
Breakpad is intended to produce minidumps for post-mortem debugging.

Original comment by ted.mielczarek on 8 Mar 2014 at 1:39

GoogleCodeExporter commented 9 years ago
Ok, how can it be done? I though breakpad already adds it's own signal handler 
to catch signals so why just don't use it to prevent crash?

Original comment by d...@antonsmirnov.name on 9 Mar 2014 at 7:07

GoogleCodeExporter commented 9 years ago
You can't prevent crashes in the general case. Once your app has crashed and 
written a minidump you should exit. You can do that in the minidump callback.

Original comment by ted.mielczarek on 10 Mar 2014 at 11:36

GoogleCodeExporter commented 9 years ago
ok, thank you

Original comment by d...@antonsmirnov.name on 10 Mar 2014 at 11:37