Bug 1343625 - Catch and gracefully handle div-by-zero exceptions in get_undecoratedNameEx. r?ted
MozReview-Commit-ID: KpQ3Gz53O6j
--- 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) {