do not crash process by default when ExceptionTracer fails to reflect over cxxabi
authorBenjamin Reesman <benr@fb.com>
Thu, 20 Jul 2017 07:08:50 +0000 (00:08 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 20 Jul 2017 07:24:22 +0000 (00:24 -0700)
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

folly/experimental/exception_tracer/ExceptionTracer.cpp

index da0b72d8abed6aec4783ecccda12eca9fd23ca1c..a5339853d7fbd30ad47a3979b1ba8456e6e3f6fd 100644 (file)
@@ -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;
 }