summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
authorGabriel Marks <gabriel.marks@mongodb.com>2022-08-16 15:48:49 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-16 16:41:44 +0000
commit6192908ab3bcf8350e9ec5c7ecc6654d5708c320 (patch)
tree4546612a4765270670d7b8f97d38b74b5594ff6f /src/mongo/util
parent2838764142c2341a8246e6039472eb9a1cdb9b7d (diff)
downloadmongo-6192908ab3bcf8350e9ec5c7ecc6654d5708c320.tar.gz
Revert "SERVER-63843 Don't allow recursive doLog in sync signal handlers"
This reverts commit 2838764142c2341a8246e6039472eb9a1cdb9b7d.
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/signal_handlers_synchronous.cpp56
1 files changed, 22 insertions, 34 deletions
diff --git a/src/mongo/util/signal_handlers_synchronous.cpp b/src/mongo/util/signal_handlers_synchronous.cpp
index 59e2e2ef923..8f052ea134b 100644
--- a/src/mongo/util/signal_handlers_synchronous.cpp
+++ b/src/mongo/util/signal_handlers_synchronous.cpp
@@ -65,8 +65,6 @@ namespace mongo {
namespace {
-using namespace fmt::literals;
-
#if defined(_WIN32)
const char* strsignal(int signalNum) {
// should only see SIGABRT on windows
@@ -193,38 +191,22 @@ private:
stdx::mutex MallocFreeOStreamGuard::_streamMutex; // NOLINT
thread_local int MallocFreeOStreamGuard::terminateDepth = 0;
-void logNoRecursion(StringData message) {
- // If we were within a log call when we hit a signal, don't call back into the logging
- // subsystem.
- if (logv2::loggingInProgress()) {
- logv2::signalSafeWriteToStderr(message);
- } else {
- LOGV2_FATAL_CONTINUE(6384300, "Writing fatal message", "message"_attr = message);
- }
-}
-
// must hold MallocFreeOStreamGuard to call
void writeMallocFreeStreamToLog() {
- mallocFreeOStream << "\n";
- logNoRecursion(mallocFreeOStream.str());
+ LOGV2_FATAL_OPTIONS(
+ 4757800,
+ logv2::LogOptions(logv2::FatalMode::kContinue, logv2::LogTruncation::Disabled),
+ "{message}",
+ "Writing fatal message",
+ "message"_attr = mallocFreeOStream.str());
mallocFreeOStream.rewind();
}
// must hold MallocFreeOStreamGuard to call
-void printStackTraceNoRecursion() {
- if (logv2::loggingInProgress()) {
- printStackTrace(mallocFreeOStream);
- writeMallocFreeStreamToLog();
- } else {
- printStackTrace();
- }
-}
-
-// must hold MallocFreeOStreamGuard to call
void printSignalAndBacktrace(int signalNum) {
- mallocFreeOStream << "Got signal: " << signalNum << " (" << strsignal(signalNum) << ").";
+ mallocFreeOStream << "Got signal: " << signalNum << " (" << strsignal(signalNum) << ").\n";
writeMallocFreeStreamToLog();
- printStackTraceNoRecursion();
+ printStackTrace();
}
// this will be called in certain c++ error cases, for example if there are two active
@@ -240,7 +222,7 @@ void myTerminate() {
mallocFreeOStream << " No exception is active";
}
writeMallocFreeStreamToLog();
- printStackTraceNoRecursion();
+ printStackTrace();
breakpoint();
endProcessWithSignal(SIGABRT);
}
@@ -259,16 +241,22 @@ void myInvalidParameterHandler(const wchar_t* expression,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved) {
-
- logNoRecursion(
- "Invalid parameter detected in function {} in {} at line {} with expression '{}'\n"_format(
- toUtf8String(function), toUtf8String(file), line, toUtf8String(expression)));
+ LOGV2_FATAL_CONTINUE(
+ 23815,
+ "Invalid parameter detected in function {function} in {file} at line {line} "
+ "with expression '{expression}'",
+ "Invalid parameter detected",
+ "function"_attr = toUtf8String(function),
+ "file"_attr = toUtf8String(file),
+ "line"_attr = line,
+ "expression"_attr = toUtf8String(expression));
abruptQuit(SIGABRT);
}
void myPureCallHandler() {
- logNoRecursion("Pure call handler invoked. Immediate exit due to invalid pure call\n");
+ LOGV2_FATAL_CONTINUE(23818,
+ "Pure call handler invoked. Immediate exit due to invalid pure call");
abruptQuit(SIGABRT);
}
@@ -357,9 +345,9 @@ void setupSynchronousSignalHandlers() {
void reportOutOfMemoryErrorAndExit() {
MallocFreeOStreamGuard lk{};
- mallocFreeOStream << "out of memory.";
+ mallocFreeOStream << "out of memory.\n";
writeMallocFreeStreamToLog();
- printStackTraceNoRecursion();
+ printStackTrace();
quickExit(EXIT_ABRUPT);
}