Commit e66b1036 authored by Yang Zhang's avatar Yang Zhang Committed by Facebook GitHub Bot

avoid stack overflow in getSingletonStackTrace()

Summary:
`sizeof(symbolizer::FrameArray<kMaxStackTraceDepth>) = 17608`, it is quite big to put on stack. When using folly::fiber we usually only have a few KB of stack space, and will overflow when calling this function.

By putting FrameArray on heap we can avoid this issue.

Reviewed By: yfeldblum

Differential Revision: D21150720

fbshipit-source-id: 7ae1d60d47b1aa3551bf96044aadad5cc21bf914
parent 8c7ef2e3
......@@ -30,19 +30,20 @@ std::string getSingletonStackTrace() {
// Get and symbolize stack trace
constexpr size_t kMaxStackTraceDepth = 100;
symbolizer::FrameArray<kMaxStackTraceDepth> addresses;
auto addresses =
std::make_unique<symbolizer::FrameArray<kMaxStackTraceDepth>>();
if (!getStackTraceSafe(addresses)) {
if (!getStackTraceSafe(*addresses)) {
return "";
} else {
constexpr size_t kDefaultCapacity = 500;
symbolizer::ElfCache elfCache(kDefaultCapacity);
symbolizer::Symbolizer symbolizer(&elfCache);
symbolizer.symbolize(addresses);
symbolizer.symbolize(*addresses);
symbolizer::StringSymbolizePrinter printer;
printer.println(addresses);
printer.println(*addresses);
return printer.str();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment