Bug 1343625 - Catch and gracefully handle div-by-zero exceptions in get_undecoratedNameEx. r?ted draft
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 03 Mar 2017 14:18:50 -0500
changeset 494175 28ad218b069120cc8fc7ebd23d594204b9a32f6e
parent 494079 517c553ad64746c479456653ce11b04ab8e4977f
child 548020 06797562ac39d08b10d73e7749e5b69bcbe5cce2
push id47945
push userkgupta@mozilla.com
push dateMon, 06 Mar 2017 18:58:14 +0000
reviewersted
bugs1343625
milestone54.0a1
Bug 1343625 - Catch and gracefully handle div-by-zero exceptions in get_undecoratedNameEx. r?ted MozReview-Commit-ID: KpQ3Gz53O6j
toolkit/crashreporter/google-breakpad/src/common/windows/pdb_source_line_writer.cc
--- a/toolkit/crashreporter/google-breakpad/src/common/windows/pdb_source_line_writer.cc
+++ b/toolkit/crashreporter/google-breakpad/src/common/windows/pdb_source_line_writer.cc
@@ -965,17 +965,30 @@ bool PDBSourceLineWriter::GetSymbolFunct
                                    UNDNAME_NO_THISTYPE |
                                    UNDNAME_NO_ACCESS_SPECIFIERS |
                                    UNDNAME_NO_THROW_SIGNATURES |
                                    UNDNAME_NO_MEMBER_TYPE |
                                    UNDNAME_NO_RETURN_UDT_MODEL |
                                    UNDNAME_NO_ECSU;
 
   // Use get_undecoratedNameEx to get readable C++ names with arguments.
-  if (function->get_undecoratedNameEx(undecorate_options, name) != S_OK) {
+  // However, on some rust symbols it can crash with a divide-by-zero,
+  // so catch that.
+  HRESULT res;
+  __try {
+    res = function->get_undecoratedNameEx(undecorate_options, name);
+  }
+  __except (GetExceptionCode() == EXCEPTION_INT_DIVIDE_BY_ZERO ?
+            EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
+  {
+    fprintf(stderr, "div-by-zero error in get_undecoratedNameEx\n");
+    // Fall through to using get_name
+    res = E_FAIL;
+  }
+  if (res != S_OK) {
     if (function->get_name(name) != S_OK) {
       fprintf(stderr, "failed to get function name\n");
       return false;
     }
 
     // It's possible for get_name to return an empty string, so
     // special-case that.
     if (wcscmp(*name, L"") == 0) {