Bug 1066175 - Only crash when crash reporting annotation succeeds. r=snorp, a=sledru
authorJim Chen <nchen@mozilla.com>
Wed, 17 Sep 2014 12:59:21 -0400
changeset 224963 2e761d32b93fb1f7e7d4b8663f91f6e5d2794598
parent 224962 84c8f07ac553b1a57b2d6877803b62aac4964df2
child 224964 da28c4c2bebf083db115319852c115be578eb20d
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, sledru
bugs1066175
milestone34.0a2
Bug 1066175 - Only crash when crash reporting annotation succeeds. r=snorp, a=sledru
widget/android/AndroidJNI.cpp
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -108,22 +108,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)
 {