Browse Source

chore: align crash patch with upstream (#23595)

Jeremy Apthorp 5 years ago
parent
commit
8b160d57a6

+ 1 - 0
patches/chromium/.patches

@@ -89,6 +89,7 @@ feat_add_onclose_to_messageport.patch
 fix_account_for_print_preview_disabled_when_printing_to_pdf.patch
 web_contents.patch
 ui_gtk_public_header.patch
+crash_allow_embedder_to_set_crash_upload_url.patch
 crash_allow_setting_more_options.patch
 breakpad_disable_upload_compression.patch
 breakpad_treat_node_processes_as_browser_processes.patch

+ 10 - 10
patches/chromium/breakpad_disable_upload_compression.patch

@@ -10,10 +10,10 @@ upload. In order to maintain that behavior, this disables compression in
 Ideally, this would be made configurable.
 
 diff --git a/components/crash/core/app/breakpad_linux.cc b/components/crash/core/app/breakpad_linux.cc
-index 364af690879d79d25d118d5b2fdbaabe21a1c52d..390cca9edc26d3153c8dbc86024cb50097d7ac78 100644
+index bb0c6aebb4fdb9b24de8292a3f1c8dc77f21e051..60a850ba3c819538f8fbf6cdcbe82290d73f1127 100644
 --- a/components/crash/core/app/breakpad_linux.cc
 +++ b/components/crash/core/app/breakpad_linux.cc
-@@ -1334,6 +1334,7 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
+@@ -1330,6 +1330,7 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
  
  #else  // defined(OS_CHROMEOS)
  
@@ -21,7 +21,7 @@ index 364af690879d79d25d118d5b2fdbaabe21a1c52d..390cca9edc26d3153c8dbc86024cb500
    // Compress |dumpfile| with gzip.
    const pid_t gzip_child = sys_fork();
    if (gzip_child < 0) {
-@@ -1377,13 +1378,16 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
+@@ -1373,13 +1374,16 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
      WriteLog(msg, sizeof(msg) - 1);
      sys__exit(1);
    }
@@ -38,12 +38,12 @@ index 364af690879d79d25d118d5b2fdbaabe21a1c52d..390cca9edc26d3153c8dbc86024cb500
    static const char header_msg[] =
        "--header=Content-Type: multipart/form-data; boundary=";
    const size_t header_content_type_size =
-@@ -1412,7 +1416,7 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
+@@ -1406,7 +1410,7 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
    static const char kWgetBinary[] = "/usr/bin/wget";
    const char* args[] = {
-     kWgetBinary,
--    header_content_encoding,
-+    //header_content_encoding,
-     header_content_type,
-     post_file,
-     upload_url,
+       kWgetBinary,
+-      header_content_encoding,
++      //header_content_encoding,
+       header_content_type,
+       post_file,
+       g_upload_url,

+ 6 - 6
patches/chromium/breakpad_treat_node_processes_as_browser_processes.patch

@@ -10,10 +10,10 @@ breakpad independently, as a "browser" process. This patches
 crash annotation.
 
 diff --git a/components/crash/core/app/breakpad_linux.cc b/components/crash/core/app/breakpad_linux.cc
-index 390cca9edc26d3153c8dbc86024cb50097d7ac78..2ae2429e6054f2d54e785c49a49fc243469bb72b 100644
+index 60a850ba3c819538f8fbf6cdcbe82290d73f1127..c5b535cb42e586a7601293c76e18355ab96eef65 100644
 --- a/components/crash/core/app/breakpad_linux.cc
 +++ b/components/crash/core/app/breakpad_linux.cc
-@@ -722,8 +722,13 @@ bool CrashDone(const MinidumpDescriptor& minidump,
+@@ -718,8 +718,13 @@ bool CrashDone(const MinidumpDescriptor& minidump,
    log_path[log_path_len] = '\0';
    info.log_filename = log_path;
  #endif
@@ -29,7 +29,7 @@ index 390cca9edc26d3153c8dbc86024cb50097d7ac78..2ae2429e6054f2d54e785c49a49fc243
    info.distro = base::g_linux_distro;
    info.distro_length = my_strlen(base::g_linux_distro);
    info.upload = upload;
-@@ -2050,8 +2055,13 @@ void InitCrashReporter(const std::string& process_type) {
+@@ -2044,8 +2049,13 @@ void InitCrashReporter(const std::string& process_type) {
        process_type == kWebViewSingleProcessType ||
        process_type == kBrowserProcessType ||
  #endif
@@ -40,6 +40,6 @@ index 390cca9edc26d3153c8dbc86024cb50097d7ac78..2ae2429e6054f2d54e785c49a49fc243
 +    g_is_node = true;
 +  }
 +
-   std::string upload_url;
-   if (GetCrashReporterClient()->GetUploadUrl(&upload_url))
-     SetUploadURL(upload_url);
+ #if !defined(OS_CHROMEOS)
+   SetUploadURL(GetCrashReporterClient()->GetUploadUrl());
+ #endif

+ 192 - 0
patches/chromium/crash_allow_embedder_to_set_crash_upload_url.patch

@@ -0,0 +1,192 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jeremy Apthorp <[email protected]>
+Date: Wed, 13 May 2020 19:06:23 +0000
+Subject: allow embedder to set crash upload url
+
+Currently //components/crash hard-codes the crash report URL to be a
+Google-specific target. This CL adds a hook which allows embedders to override
+this URL. Without it, this module isn't usable for non-Google embedders.
+
+Change-Id: I1251c3ef164f04de63cf8c66165180e897a91d78
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194585
+Commit-Queue: Jeremy Apthorp <[email protected]>
+Reviewed-by: Robert Sesek <[email protected]>
+Cr-Commit-Position: refs/heads/master@{#768385}
+
+diff --git a/components/crash/core/app/BUILD.gn b/components/crash/core/app/BUILD.gn
+index bb11c401ca7939ca04e90fd13f1b335bf5b60598..af031a027ee3e19e57e9c4d9a133127a3a637003 100644
+--- a/components/crash/core/app/BUILD.gn
++++ b/components/crash/core/app/BUILD.gn
+@@ -22,7 +22,10 @@ source_set("lib") {
+     "crash_reporter_client.h",
+   ]
+ 
+-  deps = [ "//base" ]
++  deps = [
++    "//base",
++    "//build:branding_buildflags",
++  ]
+ }
+ 
+ source_set("crashpad_handler_main") {
+diff --git a/components/crash/core/app/breakpad_linux.cc b/components/crash/core/app/breakpad_linux.cc
+index 192b0a7f137f311abb6a991f997e11f5eba52256..8ca43e2a8a104c3edf4087df5490fd47cd18f9a4 100644
+--- a/components/crash/core/app/breakpad_linux.cc
++++ b/components/crash/core/app/breakpad_linux.cc
+@@ -103,7 +103,11 @@ namespace {
+ // while we do have functions to deal with uint64_t's.
+ uint64_t g_crash_loop_before_time = 0;
+ #else
+-const char kUploadURL[] = "https://clients2.google.com/cr/report";
++char* g_upload_url = nullptr;
++void SetUploadURL(const std::string& url) {
++  DCHECK(!g_upload_url);
++  g_upload_url = strdup(url.c_str());
++}
+ #endif
+ 
+ bool g_is_crash_reporter_enabled = false;
+@@ -1400,16 +1404,16 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
+ 
+   static const char kWgetBinary[] = "/usr/bin/wget";
+   const char* args[] = {
+-    kWgetBinary,
+-    header_content_encoding,
+-    header_content_type,
+-    post_file,
+-    kUploadURL,
+-    "--timeout=10",  // Set a timeout so we don't hang forever.
+-    "--tries=1",     // Don't retry if the upload fails.
+-    "-O",  // Output reply to the file descriptor path.
+-    status_fd_path,
+-    nullptr,
++      kWgetBinary,
++      header_content_encoding,
++      header_content_type,
++      post_file,
++      g_upload_url,
++      "--timeout=10",  // Set a timeout so we don't hang forever.
++      "--tries=1",     // Don't retry if the upload fails.
++      "-O",            // Output reply to the file descriptor path.
++      status_fd_path,
++      nullptr,
+   };
+   static const char msg[] = "Cannot upload crash dump: cannot exec "
+                             "/usr/bin/wget\n";
+@@ -2037,6 +2041,10 @@ void InitCrashReporter(const std::string& process_type) {
+ #endif
+       process_type.empty();
+ 
++#if !defined(OS_CHROMEOS)
++  SetUploadURL(GetCrashReporterClient()->GetUploadUrl());
++#endif
++
+   if (is_browser_process) {
+     bool enable_breakpad = GetCrashReporterClient()->GetCollectStatsConsent() ||
+                            GetCrashReporterClient()->IsRunningUnattended();
+diff --git a/components/crash/core/app/crash_reporter_client.cc b/components/crash/core/app/crash_reporter_client.cc
+index e778f68af30f8c071d1360d06b553cc957160c5b..0ef0f00e4320b2ab1584621df5b3b8081c65a788 100644
+--- a/components/crash/core/app/crash_reporter_client.cc
++++ b/components/crash/core/app/crash_reporter_client.cc
+@@ -4,6 +4,7 @@
+ 
+ #include "components/crash/core/app/crash_reporter_client.h"
+ 
++#include "build/branding_buildflags.h"
+ #include "build/build_config.h"
+ 
+ // On Windows don't use FilePath and logging.h.
+@@ -22,6 +23,10 @@ namespace {
+ 
+ CrashReporterClient* g_client = nullptr;
+ 
++#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
++const char kDefaultUploadURL[] = "https://clients2.google.com/cr/report";
++#endif
++
+ }  // namespace
+ 
+ void SetCrashReporterClient(CrashReporterClient* client) {
+@@ -196,6 +201,16 @@ void CrashReporterClient::GetSanitizationInformation(
+ }
+ #endif
+ 
++std::string CrashReporterClient::GetUploadUrl() {
++#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
++  // Only allow the possibility of report upload in official builds. This
++  // crash server won't have symbols for any other build types.
++  return kDefaultUploadURL;
++#else
++  return std::string();
++#endif
++}
++
+ bool CrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
+   return false;
+ }
+diff --git a/components/crash/core/app/crash_reporter_client.h b/components/crash/core/app/crash_reporter_client.h
+index 9cc78fc2584061d26fd1e83b3ebf5ada0a12c138..ad4bbbc5de3feb8441ba613009452c920d925820 100644
+--- a/components/crash/core/app/crash_reporter_client.h
++++ b/components/crash/core/app/crash_reporter_client.h
+@@ -194,6 +194,9 @@ class CrashReporterClient {
+       bool* sanitize_stacks);
+ #endif
+ 
++  // Returns the URL target for crash report uploads.
++  virtual std::string GetUploadUrl();
++
+   // This method should return true to configure a crash reporter capable of
+   // monitoring itself for its own crashes to do so, even if self-monitoring
+   // would be expensive. "Expensive" self-monitoring dedicates an additional
+diff --git a/components/crash/core/app/crashpad_linux.cc b/components/crash/core/app/crashpad_linux.cc
+index 5d31d0926cd1732bdd1808c232c18fc6ff550c05..56a79e28dece162210613c842df0a34aaa66f91c 100644
+--- a/components/crash/core/app/crashpad_linux.cc
++++ b/components/crash/core/app/crashpad_linux.cc
+@@ -120,9 +120,8 @@ base::FilePath PlatformCrashpadInitialization(
+     // to ChromeOS's /sbin/crash_reporter which in turn passes the dump to
+     // crash_sender which handles the upload.
+     std::string url;
+-#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD) && \
+-    !defined(OS_CHROMEOS)
+-    url = "https://clients2.google.com/cr/report";
++#if !defined(OS_CHROMEOS)
++    url = crash_reporter_client->GetUploadUrl();
+ #else
+     url = std::string();
+ #endif
+diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
+index b579521d55860823722df2ee849f6b1628b3c950..c49d38082c41c7eb71ed2c701b06ed5b7eaa514a 100644
+--- a/components/crash/core/app/crashpad_mac.mm
++++ b/components/crash/core/app/crashpad_mac.mm
+@@ -133,13 +133,7 @@ base::FilePath PlatformCrashpadInitialization(
+       crash_reporter_client->GetCrashDumpLocation(&database_path);
+       crash_reporter_client->GetCrashMetricsLocation(&metrics_path);
+ 
+-#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
+-      // Only allow the possibility of report upload in official builds. This
+-      // crash server won't have symbols for any other build types.
+-      std::string url = "https://clients2.google.com/cr/report";
+-#else
+-      std::string url;
+-#endif
++      std::string url = crash_reporter_client->GetUploadUrl();
+ 
+       std::vector<std::string> arguments;
+ 
+diff --git a/components/crash/core/app/crashpad_win.cc b/components/crash/core/app/crashpad_win.cc
+index 669f5bea844d75f0e5c34b58994f4cfb8e856af0..c199b467ffeb007f3098ccde6879fbd71e9ec9fd 100644
+--- a/components/crash/core/app/crashpad_win.cc
++++ b/components/crash/core/app/crashpad_win.cc
+@@ -85,11 +85,7 @@ base::FilePath PlatformCrashpadInitialization(
+     std::map<std::string, std::string> process_annotations;
+     GetPlatformCrashpadAnnotations(&process_annotations);
+ 
+-#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
+-    std::string url = "https://clients2.google.com/cr/report";
+-#else
+-    std::string url;
+-#endif
++    std::string url = crash_reporter_client->GetUploadUrl();
+ 
+     // Allow the crash server to be overridden for testing. If the variable
+     // isn't present in the environment then the default URL will remain.

+ 12 - 84
patches/chromium/crash_allow_setting_more_options.patch

@@ -9,62 +9,22 @@ rate-limiting, compression and global annotations.
 This should be upstreamed.
 
 diff --git a/components/crash/core/app/breakpad_linux.cc b/components/crash/core/app/breakpad_linux.cc
-index 192b0a7f137f311abb6a991f997e11f5eba52256..364af690879d79d25d118d5b2fdbaabe21a1c52d 100644
+index 8ca43e2a8a104c3edf4087df5490fd47cd18f9a4..bb0c6aebb4fdb9b24de8292a3f1c8dc77f21e051 100644
 --- a/components/crash/core/app/breakpad_linux.cc
 +++ b/components/crash/core/app/breakpad_linux.cc
-@@ -103,9 +103,18 @@ namespace {
- // while we do have functions to deal with uint64_t's.
- uint64_t g_crash_loop_before_time = 0;
- #else
--const char kUploadURL[] = "https://clients2.google.com/cr/report";
-+const char kDefaultUploadURL[] = "https://clients2.google.com/cr/report";
-+char* g_upload_url = nullptr;
+@@ -110,6 +110,7 @@ void SetUploadURL(const std::string& url) {
+ }
  #endif
  
-+void SetUploadURL(const std::string& url) {
-+  const size_t url_len = url.size() + 1;
-+  DCHECK(!g_upload_url);
-+  g_upload_url = new char[url_len];
-+  strncpy(g_upload_url, url.c_str(), url_len);
-+}
-+
 +bool g_is_node = false;
  bool g_is_crash_reporter_enabled = false;
  uint64_t g_process_start_time = 0;
  pid_t g_pid = 0;
-@@ -1398,13 +1407,15 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
-   char* status_fd_path =
-       StringFromPrefixAndUint("/dev/fd/", upload_status_fd, allocator);
- 
-+  const char* upload_url = g_upload_url ? g_upload_url : kDefaultUploadURL;
-+
-   static const char kWgetBinary[] = "/usr/bin/wget";
-   const char* args[] = {
-     kWgetBinary,
-     header_content_encoding,
-     header_content_type,
-     post_file,
--    kUploadURL,
-+    upload_url,
-     "--timeout=10",  // Set a timeout so we don't hang forever.
-     "--tries=1",     // Don't retry if the upload fails.
-     "-O",  // Output reply to the file descriptor path.
-@@ -2037,6 +2048,10 @@ void InitCrashReporter(const std::string& process_type) {
- #endif
-       process_type.empty();
- 
-+  std::string upload_url;
-+  if (GetCrashReporterClient()->GetUploadUrl(&upload_url))
-+    SetUploadURL(upload_url);
-+
-   if (is_browser_process) {
-     bool enable_breakpad = GetCrashReporterClient()->GetCollectStatsConsent() ||
-                            GetCrashReporterClient()->IsRunningUnattended();
 diff --git a/components/crash/core/app/crash_reporter_client.cc b/components/crash/core/app/crash_reporter_client.cc
-index e778f68af30f8c071d1360d06b553cc957160c5b..b7f6ca60ef9c2367989d39e1268bf9f9a517951c 100644
+index 0ef0f00e4320b2ab1584621df5b3b8081c65a788..bb30a0fdd797b80a345212828060a38f25d78e67 100644
 --- a/components/crash/core/app/crash_reporter_client.cc
 +++ b/components/crash/core/app/crash_reporter_client.cc
-@@ -148,6 +148,17 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
+@@ -153,6 +153,17 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
    return false;
  }
  
@@ -82,19 +42,8 @@ index e778f68af30f8c071d1360d06b553cc957160c5b..b7f6ca60ef9c2367989d39e1268bf9f9
  #if defined(OS_ANDROID)
  unsigned int CrashReporterClient::GetCrashDumpPercentage() {
    return 100;
-@@ -196,6 +207,10 @@ void CrashReporterClient::GetSanitizationInformation(
- }
- #endif
- 
-+bool CrashReporterClient::GetUploadUrl(std::string* url) {
-+  return false;
-+}
-+
- bool CrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
-   return false;
- }
 diff --git a/components/crash/core/app/crash_reporter_client.h b/components/crash/core/app/crash_reporter_client.h
-index 9cc78fc2584061d26fd1e83b3ebf5ada0a12c138..aa63d7b95c37e4a143283450798b8bd500dc17a1 100644
+index ad4bbbc5de3feb8441ba613009452c920d925820..c2dfc8fc897d901d237670e7c305fd263606bee7 100644
 --- a/components/crash/core/app/crash_reporter_client.h
 +++ b/components/crash/core/app/crash_reporter_client.h
 @@ -5,6 +5,7 @@
@@ -125,18 +74,8 @@ index 9cc78fc2584061d26fd1e83b3ebf5ada0a12c138..aa63d7b95c37e4a143283450798b8bd5
  #if defined(OS_ANDROID)
    // Used by WebView to sample crashes without generating the unwanted dumps. If
    // the returned value is less than 100, crash dumping will be sampled to that
-@@ -194,6 +208,9 @@ class CrashReporterClient {
-       bool* sanitize_stacks);
- #endif
- 
-+  // Override the default upload url. Returns true if overridden.
-+  virtual bool GetUploadUrl(std::string* url);
-+
-   // This method should return true to configure a crash reporter capable of
-   // monitoring itself for its own crashes to do so, even if self-monitoring
-   // would be expensive. "Expensive" self-monitoring dedicates an additional
 diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
-index b579521d55860823722df2ee849f6b1628b3c950..f4f71e5174cf8fb706a2f8385252ba877d1a03a7 100644
+index c49d38082c41c7eb71ed2c701b06ed5b7eaa514a..7d3a52951ac525640974e03b13f8827d465adf1d 100644
 --- a/components/crash/core/app/crashpad_mac.mm
 +++ b/components/crash/core/app/crashpad_mac.mm
 @@ -67,6 +67,8 @@ std::map<std::string, std::string> GetProcessSimpleAnnotations() {
@@ -148,11 +87,7 @@ index b579521d55860823722df2ee849f6b1628b3c950..f4f71e5174cf8fb706a2f8385252ba87
    return annotations;
  }
  
-@@ -140,9 +142,17 @@ base::FilePath PlatformCrashpadInitialization(
- #else
-       std::string url;
- #endif
-+      crash_reporter_client->GetUploadUrl(&url);
+@@ -137,6 +139,13 @@ base::FilePath PlatformCrashpadInitialization(
  
        std::vector<std::string> arguments;
  
@@ -167,25 +102,18 @@ index b579521d55860823722df2ee849f6b1628b3c950..f4f71e5174cf8fb706a2f8385252ba87
          arguments.push_back("--monitor-self");
        }
 diff --git a/components/crash/core/app/crashpad_win.cc b/components/crash/core/app/crashpad_win.cc
-index 669f5bea844d75f0e5c34b58994f4cfb8e856af0..8c1fb8fb8f2e02466b51ef08de25b056f8b2052d 100644
+index c199b467ffeb007f3098ccde6879fbd71e9ec9fd..a2007514e799b77fa15cbc178d38594e4d847caa 100644
 --- a/components/crash/core/app/crashpad_win.cc
 +++ b/components/crash/core/app/crashpad_win.cc
-@@ -84,12 +84,14 @@ base::FilePath PlatformCrashpadInitialization(
+@@ -84,6 +84,7 @@ base::FilePath PlatformCrashpadInitialization(
  
      std::map<std::string, std::string> process_annotations;
      GetPlatformCrashpadAnnotations(&process_annotations);
 +    crash_reporter_client->GetProcessSimpleAnnotations(&process_annotations);
  
- #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
-     std::string url = "https://clients2.google.com/cr/report";
- #else
-     std::string url;
- #endif
-+    crash_reporter_client->GetUploadUrl(&url);
+     std::string url = crash_reporter_client->GetUploadUrl();
  
-     // Allow the crash server to be overridden for testing. If the variable
-     // isn't present in the environment then the default URL will remain.
-@@ -126,6 +128,13 @@ base::FilePath PlatformCrashpadInitialization(
+@@ -122,6 +123,13 @@ base::FilePath PlatformCrashpadInitialization(
  
      std::vector<std::string> arguments(start_arguments);
  

+ 2 - 3
shell/app/electron_crash_reporter_client.cc

@@ -194,9 +194,8 @@ bool ElectronCrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
 }
 #endif  // OS_LINUX
 
-bool ElectronCrashReporterClient::GetUploadUrl(std::string* url) {
-  *url = upload_url_;
-  return true;
+std::string ElectronCrashReporterClient::GetUploadUrl() {
+  return upload_url_;
 }
 
 bool ElectronCrashReporterClient::EnableBreakpadForProcess(

+ 1 - 1
shell/app/electron_crash_reporter_client.h

@@ -76,7 +76,7 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
 
   bool EnableBreakpadForProcess(const std::string& process_type) override;
 
-  bool GetUploadUrl(std::string* url) override;
+  std::string GetUploadUrl() override;
 
  private:
   friend class base::NoDestructor<ElectronCrashReporterClient>;