From ae910818c92677dd9a924751ed8cfc748b44a7c9 Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Mon, 20 Feb 2017 14:53:22 -0800 Subject: [PATCH] Prevent a crash in folly::Symbolizer Summary: dbg and dbgo builds of hhvm with gcc-5 crash when generating backtraces using folly::Symbolizer, because the .debug_aranges for libc-2.23.so are SHF_COMPRESSED, and folly::Symbolizer doesn't recognize that. Just pretend that the section doesn't exist if it has SHF_COMPRESSED set. We might eventually want to support decompressing such sections under an option - but folly::Symbolizer's goal is to just mmap and walk the debug info without allocating memory (so that it can run while handling signals etc). Reviewed By: pixelb Differential Revision: D4586762 fbshipit-source-id: bef61ed670d1a80caa4f7aac1f80fd2a92cc4ba9 --- folly/experimental/symbolizer/Dwarf.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/folly/experimental/symbolizer/Dwarf.cpp b/folly/experimental/symbolizer/Dwarf.cpp index 7fc1516b..c34b89ba 100644 --- a/folly/experimental/symbolizer/Dwarf.cpp +++ b/folly/experimental/symbolizer/Dwarf.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2017 Facebook, Inc. + * Copyright 2017-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #include #include @@ -304,7 +303,11 @@ bool Dwarf::getSection(const char* name, folly::StringPiece* section) const { if (!elfSection) { return false; } - +#ifdef SHF_COMPRESSED + if (elfSection->sh_flags & SHF_COMPRESSED) { + return false; + } +#endif *section = elf_->getSectionBody(*elfSection); return true; } @@ -318,7 +321,6 @@ void Dwarf::init() { elf_ = nullptr; return; } - getSection(".debug_str", &strings_); // Optional: fast address range lookup. If missing .debug_info can // be used - but it's much slower (linear scan). -- 2.34.1