应用程序甚至google_breakpad捕获信号后坠毁? [英] App crashed even after catching signal by google_breakpad?

查看:362
本文介绍了应用程序甚至google_breakpad捕获信号后坠毁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌breakpad捕获信号(约合通过JNI崩溃本土code),但它后仍然应用死亡。哪些应该按顺序做prevent呢?

日志:

  15 03-08:04:13.398:ERROR / NATIVE_LIB(2828):初始化breakpad
03-08 15:04:13.398:ERROR / NATIVE_LIB(2828):碰撞测试
03-08 15:04:13.468:ERROR / NATIVE_LIB(2828):转储路径:./5f6097b2-5feb-0723-3271a7ff-2a4fcadd.dmp
03-08 15:04:13.468:WARN / crash_handler(2828):陷入崩溃,正负号= 11...03-08 15:04:14.589:信息/ ActivityManager(544):进程name.antonsmirnov.android.app(PID 2828)已经死亡。

code:

 的#includenative_lib.h#包括LT&;&stdio.h中GT;#包括客户端/ Linux的/处理器/ exception_handler.h
#包括客户端/ Linux的/处理器/ minidump_descriptor.h#包括LT&;机器人/ log.h>无效调试(为const char *格式,...){
    va_list的argptr;
    的va_start(argptr,格式);
    __android_log_vprint(ANDROID_LOG_ERRORNATIVE_LIB,格式,argptr);
    va_end用来(argptr);
}布尔DumpCallback(常量google_breakpad :: MinidumpDesc​​riptor&放大器;描述,
                  void *的背景下,
                  布尔成功){
  调试(转储路径:%S \\ n,descriptor.path());
  返回成功;
}JNIEXPORT jint JNICALL Java_name_antonsmirnov_android_app_libnative_func(JNIEnv的* ENV,jobject OBJ)
{
    调试(INIT breakpad);
    google_breakpad :: MinidumpDesc​​riptor描述符(。);
    google_breakpad ::诶的ExceptionHandler(描述,NULL,DumpCallback,NULL,真实,-1);    {
        调试(测试崩溃\\ n);        字符* PTR = 0;
        * PTR =''; // ERROR HERE!
        调试(无法访问\\ n);    }    调试(说完\\ n);
}


解决方案

在某些情况下,有pventing崩溃您的应用程序没有$ P $的方式,即使你使用 Breakpad 或<强> CoffeeCatch

然而,发生在飞机坠毁前将通知您。你可以利用这段时间来警告发生了什么用户(致命错误)和next(应用程序将强制关闭)。

会发生什么

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

解决方案

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).

这篇关于应用程序甚至google_breakpad捕获信号后坠毁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆