App crashed even after catching signal by google_breakpad?

青春壹個敷衍的年華 提交于 2019-12-13 04:34:28

问题


Google breakpad catches signal (about crash in native code via JNI) but the app still dies after it. What should be done in order to prevent it?

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:14.589: INFO/ActivityManager(544): Process name.antonsmirnov.android.app (pid 2828) has died.

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_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");
}

回答1:


In some cases, there is no way of preventing your app from crashing, even if you use Breakpad or CoffeeCatch.

However, you will be notified before the crash occurs. You can use that time to warn the user about what is happening (a fatal error) and what will happen next (the app will force close).



来源:https://stackoverflow.com/questions/22267382/app-crashed-even-after-catching-signal-by-google-breakpad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!