Bug 1066175 - Only crash when crash reporting annotation succeeds; r=snorp
authorJim Chen <nchen@mozilla.com>
Wed, 17 Sep 2014 12:59:21 -0400
changeset 205876 20704dcbd2533c0f27ed15719665f6ff7563618c
parent 205875 a0118051b162e25389815b2f855c6d726f5c4101
child 205877 92ffb3d125f68228655fee53f62e8f1ab12ba367
push id27507
push userryanvm@gmail.com
push dateThu, 18 Sep 2014 02:16:54 +0000
treeherdermozilla-central@488d490da742 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1066175
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1066175 - Only crash when crash reporting annotation succeeds; r=snorp
widget/android/AndroidJNI.cpp
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -131,22 +131,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)
 {