Bug 1066175 - Only crash when crash reporting annotation succeeds. r=snorp, a=sledru
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -90,22 +90,25 @@ Java_org_mozilla_gecko_GeckoAppShell_onR
if (nsAppShell::gAppShell)
nsAppShell::gAppShell->OnResume();
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash(JNIEnv *jenv, jclass, jstring jStackTrace)
{
#ifdef MOZ_CRASHREPORTER
- const nsJNIString stackTrace16(jStackTrace, jenv);
- const NS_ConvertUTF16toUTF8 stackTrace8(stackTrace16);
- CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("JavaStackTrace"), stackTrace8);
+ const nsJNICString stackTrace(jStackTrace, jenv);
+ if (NS_WARN_IF(NS_FAILED(CrashReporter::AnnotateCrashReport(
+ NS_LITERAL_CSTRING("JavaStackTrace"), stackTrace)))) {
+ // Only crash below if crash reporter is initialized and annotation succeeded.
+ // Otherwise try other means of reporting the crash in Java.
+ return;
+ }
#endif // MOZ_CRASHREPORTER
-
- abort();
+ MOZ_CRASH("Uncaught Java exception");
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange(JNIEnv* jenv, jclass,
jdouble aLevel,
jboolean aCharging,
jdouble aRemainingTime)
{