tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

37_neuter_DumpWithoutCrashing.patch (3926B)


      1 # HG changeset patch
      2 # User Bob Owen <bobowencode@gmail.com>
      3 Neuter DumpWithoutCrashing.
      4 
      5 This avoids bringing in more dependencies and we wouldn't have a way of
      6 processing these dumps within our current infrastructure.
      7 This also removes use of feature kNotReachedIsFatal.
      8 
      9 diff --git a/base/check.cc b/base/check.cc
     10 --- a/base/check.cc
     11 +++ b/base/check.cc
     12 @@ -8,63 +8,73 @@
     13 #include "base/debug/alias.h"
     14 #include "base/debug/dump_without_crashing.h"
     15 #include "base/feature_list.h"
     16 #include "base/features.h"
     17 #include "base/logging.h"
     18 #include "base/thread_annotations.h"
     19 #include "build/build_config.h"
     20 
     21 +#if !defined(MOZ_SANDBOX)
     22 #if !BUILDFLAG(IS_NACL)
     23 #include "base/debug/crash_logging.h"
     24 #endif  // !BUILDFLAG(IS_NACL)
     25 +#endif
     26 
     27 namespace logging {
     28 
     29 namespace {
     30 
     31 +#if !defined(MOZ_SANDBOX)
     32 void DumpWithoutCrashing(LogMessage* log_message,
     33                          const base::Location& location) {
     34   // Copy the LogMessage message to stack memory to make sure it can be
     35   // recovered in crash dumps. This is easier to recover in minidumps than crash
     36   // keys during local debugging.
     37   DEBUG_ALIAS_FOR_CSTR(log_message_str, log_message->BuildCrashString().c_str(),
     38                        1024);
     39 
     40   // Report from the same location at most once every 30 days (unless the
     41   // process has died). This attempts to prevent us from flooding ourselves with
     42   // repeat reports for the same bug.
     43   base::debug::DumpWithoutCrashing(location, base::Days(30));
     44 }
     45 +#endif
     46 
     47 void NotReachedDumpWithoutCrashing(LogMessage* log_message,
     48                                    const base::Location& location) {
     49 +#if !defined(MOZ_SANDBOX)
     50 #if !BUILDFLAG(IS_NACL)
     51   SCOPED_CRASH_KEY_STRING1024("Logging", "NOTREACHED_MESSAGE",
     52                               log_message->BuildCrashString());
     53 #endif  // !BUILDFLAG(IS_NACL)
     54   DumpWithoutCrashing(log_message, location);
     55 +#endif
     56 }
     57 
     58 void DCheckDumpWithoutCrashing(LogMessage* log_message,
     59                                const base::Location& location) {
     60 +#if !defined(MOZ_SANDBOX)
     61 #if !BUILDFLAG(IS_NACL)
     62   SCOPED_CRASH_KEY_STRING1024("Logging", "DCHECK_MESSAGE",
     63                               log_message->BuildCrashString());
     64 #endif  // !BUILDFLAG(IS_NACL)
     65   DumpWithoutCrashing(log_message, location);
     66 +#endif
     67 }
     68 
     69 void DumpWillBeCheckDumpWithoutCrashing(LogMessage* log_message,
     70                                         const base::Location& location) {
     71 +#if !defined(MOZ_SANDBOX)
     72 #if !BUILDFLAG(IS_NACL)
     73   SCOPED_CRASH_KEY_STRING1024("Logging", "DUMP_WILL_BE_CHECK_MESSAGE",
     74                               log_message->BuildCrashString());
     75 #endif  // !BUILDFLAG(IS_NACL)
     76   DumpWithoutCrashing(log_message, location);
     77 +#endif
     78 }
     79 
     80 class NotReachedLogMessage : public LogMessage {
     81  public:
     82   NotReachedLogMessage(const base::Location& location, LogSeverity severity)
     83       : LogMessage(location.file_name(), location.line_number(), severity),
     84         location_(location) {}
     85   ~NotReachedLogMessage() override {
     86 @@ -281,21 +291,23 @@ CheckError::~CheckError() {
     87   // LOG(FATAL) is [[noreturn]] and can't be overridden.
     88   if (is_fatal) {
     89     base::ImmediateCrash();
     90   }
     91 }
     92 
     93 NotReachedError NotReachedError::NotReached(const base::Location& location) {
     94   const LogSeverity severity = []() {
     95 +#if !defined(MOZ_SANDBOX)
     96     // NOTREACHED() instances may be hit before base::FeatureList is enabled.
     97     if (base::FeatureList::GetInstance() &&
     98         base::FeatureList::IsEnabled(base::features::kNotReachedIsFatal)) {
     99       return LOGGING_FATAL;
    100     }
    101 +#endif
    102     return DCHECK_IS_ON() ? LOGGING_DCHECK : LOGGING_ERROR;
    103   }();
    104   auto* const log_message = new NotReachedLogMessage(location, severity);
    105 
    106   // TODO(pbos): Consider a better message for NotReached(), this is here to
    107   // match existing behavior + test expectations.
    108   log_message->stream() << "Check failed: false. ";
    109   return NotReachedError(log_message);