Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3261)

Unified Diff: base/logging.cc

Issue 2377963002: restore LOG_FATAL crash key on windows
Patch Set: return protection against reentrancy Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | blimp/engine/app/blimp_engine_crash_keys.cc » ('j') | chrome/common/crash_keys.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.cc
diff --git a/base/logging.cc b/base/logging.cc
index 0771b47c182e5c18c868f1124a0784bf411d74a9..303d820733e242fd1a65f63f2433e119076700e2 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -53,9 +53,11 @@ typedef pthread_mutex_t* MutexHandle;
#include <ostream>
#include <string>
+#include "base/auto_reset.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/alias.h"
+#include "base/debug/crash_logging.h"
#include "base/debug/debugger.h"
#include "base/debug/stack_trace.h"
#include "base/posix/eintr_wrapper.h"
@@ -537,6 +539,22 @@ LogMessage::~LogMessage() {
stream_ << std::endl;
std::string str_newline(stream_.str());
+// NaCl targets do not have base/debug/crash_logging.cc.
+#if !defined(OS_NACL)
+ if (severity_ == LOG_FATAL) {
+ // In case of an out-of-memory condition, this code could be reentered when
+ // constructing and storing the key. Using a static is not thread-safe, but
+ // if multiple threads are in the process of a fatal crash at the same time,
+ // this should work.
+ static bool guarded = false;
+ if (!guarded) {
+ base::AutoReset<bool> guard(&guarded, true);
+ base::debug::SetCrashKeyValue(
+ "LOG_FATAL", base::StringPiece(str_newline.c_str() + message_start_));
+ }
+ }
+#endif // !defined(OS_NACL)
+
// Give any log message handler first dibs on the message.
if (log_message_handler &&
log_message_handler(severity_, file_, line_,
« no previous file with comments | « no previous file | blimp/engine/app/blimp_engine_crash_keys.cc » ('j') | chrome/common/crash_keys.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698