From: Benjamin Reesman <benr@fb.com>
Date: Thu, 20 Jul 2017 07:08:50 +0000 (-0700)
Subject: do not crash process by default when ExceptionTracer fails to reflect over cxxabi
X-Git-Tag: v2017.07.24.00~17
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=05a686a79a3babca628fd3be34c86a6140031970;p=folly.git

do not crash process by default when ExceptionTracer fails to reflect over cxxabi

Summary: It is possible in certain cirucmstances for the cxxabi reflection code in `ExceptionTracer` to fail to cope with exceptions that we've seen in production and it currently aborts the process in that case. This diff switches this to `DFATAL`/`DCHECK`.

Reviewed By: yfeldblum

Differential Revision: D5431445

fbshipit-source-id: c3d68372c2fadbb518f78fe99e817db611953d22
---

diff --git a/folly/experimental/exception_tracer/ExceptionTracer.cpp b/folly/experimental/exception_tracer/ExceptionTracer.cpp
index da0b72d8..a5339853 100644
--- a/folly/experimental/exception_tracer/ExceptionTracer.cpp
+++ b/folly/experimental/exception_tracer/ExceptionTracer.cpp
@@ -162,16 +162,25 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
       isAbiCppException(currentException) ?
       currentException->exceptionType :
       nullptr;
+
     if (traceStack) {
-      CHECK(trace) << "Invalid trace stack!";
-      info.frames.assign(trace->addresses,
-                         trace->addresses + trace->frameCount);
+      LOG_IF(DFATAL, !trace)
+          << "Invalid trace stack for exception of type: "
+          << (info.type ? folly::demangle(*info.type) : "null");
+
+      if (!trace) {
+        return {};
+      }
+
+      info.frames.assign(
+          trace->addresses, trace->addresses + trace->frameCount);
       trace = traceStack->next(trace);
     }
     currentException = currentException->nextException;
     exceptions.push_back(std::move(info));
   }
-  CHECK(!trace) << "Invalid trace stack!";
+
+  LOG_IF(DFATAL, trace) << "Invalid trace stack!";
 
   return exceptions;
 }