From 05a686a79a3babca628fd3be34c86a6140031970 Mon Sep 17 00:00:00 2001 From: Benjamin Reesman Date: Thu, 20 Jul 2017 00:08:50 -0700 Subject: [PATCH] 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 --- .../exception_tracer/ExceptionTracer.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 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; } -- 2.34.1