Leak ELF file cache that the signal handler uses
authorTudor Bosman <tudorb@fb.com>
Mon, 24 Feb 2014 23:39:46 +0000 (15:39 -0800)
committerDave Watson <davejwatson@fb.com>
Fri, 28 Feb 2014 22:02:05 +0000 (14:02 -0800)
Summary: so we can still handle signals during global destruction. (d'oh)

Test Plan: unittests

Reviewed By: philipp@fb.com

FB internal diff: D1188159

folly/experimental/symbolizer/SignalHandler.cpp

index 02e5ef05219c58fa43d6c7fb3f8c81f40c63fa47..79f17f98e8f41bf195c4c06c6c78c164a5479825 100644 (file)
@@ -193,7 +193,9 @@ constexpr size_t kDefaultCapacity = 500;
 
 // Note: not thread-safe, but that's okay, as we only let one thread
 // in our signal handler at a time.
-SignalSafeElfCache signalSafeElfCache(kDefaultCapacity);
+//
+// Leak it so we don't have to worry about destruction order
+auto gSignalSafeElfCache = new SignalSafeElfCache(kDefaultCapacity);
 }  // namespace
 
 void dumpStackTrace(bool symbolize) __attribute__((noinline));
@@ -208,7 +210,7 @@ void dumpStackTrace(bool symbolize) {
   if (!getStackTraceSafe(addresses)) {
     print("(error retrieving stack trace)\n");
   } else if (symbolize) {
-    Symbolizer symbolizer(&signalSafeElfCache);
+    Symbolizer symbolizer(gSignalSafeElfCache);
     symbolizer.symbolize(addresses);
 
     FDSymbolizePrinter printer(STDERR_FILENO, SymbolizePrinter::COLOR_IF_TTY);