Commit 23cadde7 authored by Matt Ma's avatar Matt Ma Committed by Facebook GitHub Bot

Back out "Resubmit: Allow using different symbolizer mode in signal handler."

Summary:
Original commit changeset: 25d4049019e4

Base diff broke fboss build (using fbcode_builder) with the following error:

/tmp/fbcode_builder_getdeps-ZrootZfboss2.gitZbuildZfbcode_builder-root/installed/folly/include/folly/init/Init.h:22:10: fatal error: folly/experimental/symbolizer/SymbolizerMode.h: No such file or directory
 #include <folly/experimental/symbolizer/SymbolizerMode.h>

Revert this first to unblock fboss while I am investigating the failure.

Reviewed By: shri-khare

Differential Revision: D22077183

fbshipit-source-id: 8bafc0518df82c61922104b7d59ef5ee20fdd572
parent 1e22eb61
......@@ -30,7 +30,6 @@
#include <folly/experimental/exception_tracer/ExceptionAbi.h>
#include <folly/experimental/exception_tracer/StackTrace.h>
#include <folly/experimental/symbolizer/Symbolizer.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
namespace {
......
......@@ -24,7 +24,6 @@
#include <folly/Range.h>
#include <folly/experimental/symbolizer/Elf.h>
#include <folly/experimental/symbolizer/SymbolizedFrame.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
namespace folly {
namespace symbolizer {
......
......@@ -493,9 +493,7 @@ bool isSmallSigAltStackEnabled() {
} // namespace
void installFatalSignalHandler(
std::bitset<64> signals,
LocationInfoMode symbolizerMode) {
void installFatalSignalHandler(std::bitset<64> signals) {
if (gAlreadyInstalled.exchange(true)) {
// Already done.
return;
......@@ -511,11 +509,9 @@ void installFatalSignalHandler(
// stack overflow. Replace it with the unsafe self-allocate printer.
bool useUnsafePrinter = isSmallSigAltStackEnabled();
if (useUnsafePrinter) {
gStackTracePrinter =
new UnsafeSelfAllocateStackTracePrinter(STDERR_FILENO, symbolizerMode);
gStackTracePrinter = new UnsafeSelfAllocateStackTracePrinter();
} else {
gStackTracePrinter =
new SafeStackTracePrinter(STDERR_FILENO, symbolizerMode);
gStackTracePrinter = new SafeStackTracePrinter();
}
struct sigaction sa;
......
......@@ -19,9 +19,6 @@
#include <bitset>
#include <functional>
#include <folly/experimental/symbolizer/SymbolizedFrame.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
namespace folly {
namespace symbolizer {
......@@ -39,8 +36,7 @@ extern const unsigned long kAllFatalSignals;
* are honored in this list, other signals are ignored.
*/
void installFatalSignalHandler(
std::bitset<64> signals = std::bitset<64>(kAllFatalSignals),
LocationInfoMode symbolizerMode = LocationInfoMode::FULL);
std::bitset<64> signals = std::bitset<64>(kAllFatalSignals));
/**
* Add a callback to be run when receiving a fatal signal. They will also
......
......@@ -80,6 +80,18 @@ inline std::ostream& operator<<(std::ostream& out, const Path& path) {
return out << path.toString();
}
enum class LocationInfoMode {
// Don't resolve location info.
DISABLED,
// Perform CU lookup using .debug_aranges (might be incomplete).
FAST,
// Scan all CU in .debug_info (slow!) on .debug_aranges lookup failure.
FULL,
// Scan .debug_info (super slower, use with caution) for inline functions in
// addition to FULL.
FULL_WITH_INLINE,
};
/**
* Contains location info like file name, line number, etc.
*/
......
......@@ -472,9 +472,8 @@ void StringSymbolizePrinter::doPrint(StringPiece sp) {
buf_.append(sp.data(), sp.size());
}
SafeStackTracePrinter::SafeStackTracePrinter(int fd, LocationInfoMode mode)
SafeStackTracePrinter::SafeStackTracePrinter(int fd)
: fd_(fd),
mode_(mode),
printer_(
fd,
SymbolizePrinter::COLOR_IF_TTY,
......@@ -494,19 +493,15 @@ void SafeStackTracePrinter::printSymbolizedStackTrace() {
// Do our best to populate location info, process is going to terminate,
// so performance isn't critical.
SignalSafeElfCache elfCache_;
Symbolizer symbolizer(&elfCache_, mode_);
Symbolizer symbolizer(&elfCache_, LocationInfoMode::FULL);
symbolizer.symbolize(*addresses_);
// Skip the top 2 frames (4 frames if inline functions are included) captured
// by printStackTrace:
// * getStackTraceInPlace (marked as inline in StackTrace.cpp)
// getStackTraceSafe (in StackTrace.cpp)
// * getStackTraceSafe<N> (marked as inline in Symbolizer.h)
// Skip the top 2 frames captured by printStackTrace:
// getStackTraceSafe
// SafeStackTracePrinter::printStackTrace (captured stack)
//
// Leaving signalHandler on the stack for clarity, I think.
printer_.println(
*addresses_, mode_ == LocationInfoMode::FULL_WITH_INLINE ? 4 : 2);
printer_.println(*addresses_, 2);
}
void SafeStackTracePrinter::printStackTrace(bool symbolize) {
......
......@@ -32,7 +32,6 @@
#include <folly/experimental/symbolizer/ElfCache.h>
#include <folly/experimental/symbolizer/StackTrace.h>
#include <folly/experimental/symbolizer/SymbolizedFrame.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
#include <folly/io/IOBuf.h>
namespace folly {
......@@ -126,10 +125,9 @@ class Symbolizer {
template <size_t N>
size_t symbolize(FrameArray<N>& fa) {
fa.frameCount = symbolize(
return symbolize(
folly::Range<const uintptr_t*>(fa.addresses, fa.frameCount),
folly::Range<SymbolizedFrame*>(fa.frames, N));
return fa.frameCount;
}
/**
......@@ -349,9 +347,7 @@ class StringSymbolizePrinter : public SymbolizePrinter {
*/
class SafeStackTracePrinter {
public:
explicit SafeStackTracePrinter(
int fd = STDERR_FILENO,
LocationInfoMode mode = LocationInfoMode::FULL);
explicit SafeStackTracePrinter(int fd = STDERR_FILENO);
virtual ~SafeStackTracePrinter() {}
......@@ -378,8 +374,7 @@ class SafeStackTracePrinter {
private:
static constexpr size_t kMaxStackTraceDepth = 100;
const int fd_;
const LocationInfoMode mode_;
int fd_;
FDSymbolizePrinter printer_;
std::unique_ptr<FrameArray<kMaxStackTraceDepth>> addresses_;
};
......@@ -427,12 +422,6 @@ class FastStackTracePrinter {
* Note it's still unsafe even with that.
*/
class UnsafeSelfAllocateStackTracePrinter : public SafeStackTracePrinter {
public:
explicit UnsafeSelfAllocateStackTracePrinter(
int fd = STDERR_FILENO,
LocationInfoMode mode = LocationInfoMode::FULL)
: SafeStackTracePrinter(fd, mode) {}
protected:
void printSymbolizedStackTrace() override;
const long pageSizeUnchecked_ = sysconf(_SC_PAGESIZE);
......
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
namespace folly {
namespace symbolizer {
enum class LocationInfoMode {
// Don't resolve location info.
DISABLED,
// Perform CU lookup using .debug_aranges (might be incomplete).
FAST,
// Scan all CU in .debug_info (slow!) on .debug_aranges lookup failure.
FULL,
// Scan .debug_info (super slower, use with caution) for inline functions in
// addition to FULL.
FULL_WITH_INLINE,
};
} // namespace symbolizer
} // namespace folly
......@@ -18,7 +18,6 @@
#include <folly/Range.h>
#include <folly/experimental/symbolizer/Dwarf.h>
#include <folly/experimental/symbolizer/SymbolizedFrame.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
#include <folly/experimental/symbolizer/test/SymbolizerTestUtils.h>
#include <folly/portability/GFlags.h>
......
......@@ -19,7 +19,6 @@
#include <folly/experimental/TestUtil.h>
#include <folly/experimental/symbolizer/StackTrace.h>
#include <folly/experimental/symbolizer/Symbolizer.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
#include <folly/test/TestUtils.h>
#include <boost/regex.hpp>
......
......@@ -23,7 +23,6 @@
#include <folly/Range.h>
#include <folly/String.h>
#include <folly/experimental/symbolizer/SymbolizedFrame.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
#include <folly/experimental/symbolizer/test/SymbolizerTestUtils.h>
#include <folly/portability/GTest.h>
#include <folly/test/TestUtils.h>
......
......@@ -25,10 +25,7 @@
#include <folly/synchronization/HazptrThreadPoolExecutor.h>
#if FOLLY_USE_SYMBOLIZER
// @manual because autodeps doesn't understand `os_deps` and suggests
// adding dep to `deps`.
#include <folly/experimental/symbolizer/SignalHandler.h> // @manual
#include <folly/experimental/symbolizer/SymbolizedFrame.h> // @manual
#endif
#include <folly/portability/GFlags.h>
......@@ -54,8 +51,7 @@ void init(int* argc, char*** argv, InitOptions options) {
#if FOLLY_USE_SYMBOLIZER
// Install the handler now, to trap errors received during startup.
// The callbacks, if any, can be installed later
folly::symbolizer::installFatalSignalHandler(
options.fatal_signals, options.fatalSignalsSymbolizerMode);
folly::symbolizer::installFatalSignalHandler(options.fatal_signals);
#elif !defined(_WIN32)
google::InstallFailureSignalHandler();
#endif
......
......@@ -15,11 +15,8 @@
*/
#pragma once
#include <bitset>
#include <folly/CPortability.h>
#include <folly/experimental/symbolizer/SymbolizerMode.h>
#include <bitset>
namespace folly {
class InitOptions {
......@@ -28,17 +25,13 @@ class InitOptions {
bool remove_flags{true};
// Mask of all fatal (default handler of terminating the process) signals for
// mask of all fatal (default handler of terminating the process) signals for
// which `init()` will install handler that print stack traces and invokes
// previously established handler (or terminate if there were none).
// Signals that are not in `symbolizer::kAllFatalSignals` will be ignored
// if passed here.
// Defaults to all signal in `symbolizer::kAllFatalSignals`.
// Both fatal_signals and symbolizerMode are only used when folly symbolizer
// is enabled.
// if passed here
// Defaults to all signal in `symbolizer::kAllFatalSignals`
std::bitset<64> fatal_signals;
folly::symbolizer::LocationInfoMode fatalSignalsSymbolizerMode =
folly::symbolizer::LocationInfoMode::FULL;
InitOptions& removeFlags(bool remove) {
remove_flags = remove;
......
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