Bug 1516367 - Move the minidump-analyzer out of the crash reporter application bundle r=spohl,dmajor
authorGabriele Svelto <gsvelto@mozilla.com>
Thu, 14 Nov 2019 21:11:59 +0000
changeset 502056 5df0e903d13fa096db7b3d90c3d1fe972a5b34d4
parent 502055 f0ceeb68fff9ceb3d8ec9f7915695a8ed8ae9e27
child 502057 8fa2316b02404d9fde7a88fe6948df683a2f84a0
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl, dmajor
bugs1516367
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1516367 - Move the minidump-analyzer out of the crash reporter application bundle r=spohl,dmajor The minidump-analyzer tool was originally conceived to be used from the crash report client and as such was installed in the crash reporter client application bundle on macOS. It was later adapted to work from Firefox itself but this caused linking problems when invoked from the Firefox app bundle. This patch moves the minidump-analyzer into the Firefox app bundle and adapts the relevant code to find it there. The minidump-analyzer was also not signed like the rest of our executables and this patch addresses that issue too. Differential Revision: https://phabricator.services.mozilla.com/D52910
browser/app/macbuild/Contents/MacOS-files.in
browser/installer/package-manifest.in
python/mozbuild/mozbuild/artifacts.py
security/mac/hardenedruntime/codesign.bash
toolkit/components/crashes/CrashService.jsm
toolkit/crashreporter/client/crashreporter.cpp
toolkit/crashreporter/client/crashreporter.h
toolkit/crashreporter/minidump-analyzer/moz.build
--- a/browser/app/macbuild/Contents/MacOS-files.in
+++ b/browser/app/macbuild/Contents/MacOS-files.in
@@ -5,14 +5,17 @@
 /firefox-bin
 #if defined(MOZ_GECKODRIVER)
 /geckodriver
 #endif
 /gtest/***
 #if defined(MOZ_ASAN) || defined(MOZ_TSAN)
 /llvm-symbolizer
 #endif
+#if defined(MOZ_CRASHREPORTER)
+/minidump-analyzer
+#endif
 /pingsender
 /pk12util
 /ssltunnel
 /webrtc-gtest
 /xpcshell
 /XUL
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -405,27 +405,32 @@ bin/libfreebl_64int_3.so
 ; [Crash Reporter]
 ;
 #ifdef MOZ_CRASHREPORTER
 #ifdef XP_MACOSX
 @BINPATH@/crashreporter.app/
 #else
 @BINPATH@/crashreporter@BIN_SUFFIX@
 @RESPATH@/crashreporter.ini
-@BINPATH@/minidump-analyzer@BIN_SUFFIX@
 #ifdef XP_UNIX
 @RESPATH@/Throbber-small.gif
 #endif
 #endif
 @RESPATH@/browser/crashreporter-override.ini
 #ifdef MOZ_CRASHREPORTER_INJECTOR
 @BINPATH@/breakpadinjector.dll
 #endif
 #endif
 
+; [ minidump-analyzer ]
+;
+#ifdef MOZ_CRASHREPORTER
+@BINPATH@/minidump-analyzer@BIN_SUFFIX@
+#endif
+
 ; [ Ping Sender ]
 ;
 @BINPATH@/pingsender@BIN_SUFFIX@
 
 ; Shutdown Terminator
 @RESPATH@/components/terminator.manifest
 
 #ifdef LLVM_SYMBOLIZER
--- a/python/mozbuild/mozbuild/artifacts.py
+++ b/python/mozbuild/mozbuild/artifacts.py
@@ -455,16 +455,17 @@ class MacArtifactJob(ArtifactJob):
         'libnssckbi.dylib',
         'libnssdbm3.dylib',
         'libplugin_child_interpose.dylib',
         # 'libreplace_jemalloc.dylib',
         # 'libreplace_malloc.dylib',
         'libmozavutil.dylib',
         'libmozavcodec.dylib',
         'libsoftokn3.dylib',
+        'minidump-analyzer',
         'pingsender',
         'plugin-container.app/Contents/MacOS/plugin-container',
         'updater.app/Contents/MacOS/org.mozilla.updater',
         # 'xpcshell',
         'XUL',
     ])
 
     @property
@@ -499,19 +500,16 @@ class MacArtifactJob(ArtifactJob):
 
             bundle_dirs = glob.glob(mozpath.join(tempdir, '*.app'))
             if len(bundle_dirs) != 1:
                 raise ValueError('Expected one source bundle, found: {}'.format(bundle_dirs))
             [source] = bundle_dirs
 
             # These get copied into dist/bin with the path, so "root/a/b/c" -> "dist/bin/a/b/c".
             paths_keep_path = [
-                ('Contents/MacOS', [
-                    'crashreporter.app/Contents/MacOS/minidump-analyzer',
-                ]),
                 ('Contents/Resources', [
                     'browser/components/libbrowsercomps.dylib',
                     'dependentlibs.list',
                     # 'firefox',
                     'gmp-clearkey/0.1/libclearkey.dylib',
                     # 'gmp-fake/1.0/libfake.dylib',
                     # 'gmp-fakeopenh264/1.0/libfakeopenh264.dylib',
                 ]),
--- a/security/mac/hardenedruntime/codesign.bash
+++ b/security/mac/hardenedruntime/codesign.bash
@@ -112,16 +112,17 @@ echo "----------------------------------
 # Clear extended attributes which cause codesign to fail
 xattr -cr "${BUNDLE}"
 
 # Sign these binaries first. Signing of some binaries has an ordering
 # requirement where other binaries must be signed first.
 codesign --force -o runtime --verbose --sign "$IDENTITY" \
 "${BUNDLE}/Contents/MacOS/XUL" \
 "${BUNDLE}/Contents/MacOS/pingsender" \
+"${BUNDLE}/Contents/MacOS/minidump-analyzer" \
 "${BUNDLE}"/Contents/MacOS/*.dylib
 
 codesign --force -o runtime --verbose --sign "$IDENTITY" --deep \
 "${BUNDLE}"/Contents/MacOS/crashreporter.app
 
 codesign --force -o runtime --verbose --sign "$IDENTITY" --deep \
 "${BUNDLE}"/Contents/MacOS/updater.app
 
--- a/toolkit/components/crashes/CrashService.jsm
+++ b/toolkit/components/crashes/CrashService.jsm
@@ -31,23 +31,16 @@ var gRunningProcesses = new Set();
  */
 function runMinidumpAnalyzer(minidumpPath, allThreads) {
   return new Promise((resolve, reject) => {
     try {
       const binSuffix = AppConstants.platform === "win" ? ".exe" : "";
       const exeName = "minidump-analyzer" + binSuffix;
 
       let exe = Services.dirsvc.get("GreBinD", Ci.nsIFile);
-
-      if (AppConstants.platform === "macosx") {
-        exe.append("crashreporter.app");
-        exe.append("Contents");
-        exe.append("MacOS");
-      }
-
       exe.append(exeName);
 
       let args = [minidumpPath];
       let process = Cc["@mozilla.org/process/util;1"].createInstance(
         Ci.nsIProcess
       );
       process.init(exe);
       process.startHidden = true;
--- a/toolkit/crashreporter/client/crashreporter.cpp
+++ b/toolkit/crashreporter/client/crashreporter.cpp
@@ -526,16 +526,26 @@ bool CheckEndOfLifed(string version) {
   string reportPath = gSettingsPath + UI_DIR_SEPARATOR + "EndOfLife" + version;
   return UIFileExists(reportPath);
 }
 
 static string GetProgramPath(const string& exename) {
   string path = gArgv[0];
   size_t pos = path.rfind(UI_CRASH_REPORTER_FILENAME BIN_SUFFIX);
   path.erase(pos);
+#ifdef XP_MACOSX
+  // On macOS the crash reporter client is shipped as an application bundle
+  // contained within Firefox' main application bundle. So when it's invoked
+  // its current working directory looks like:
+  // Firefox.app/Contents/MacOS/crashreporter.app/Contents/MacOS/
+  // The other applications we ship with Firefox are stored in the main bundle
+  // (Firefox.app/Contents/MacOS/) so we we need to go back three directories
+  // to reach them.
+  path.append("../../../");
+#endif  // XP_MACOSX
   path.append(exename + BIN_SUFFIX);
 
   return path;
 }
 
 int main(int argc, char** argv) {
   gArgc = argc;
   gArgv = argv;
--- a/toolkit/crashreporter/client/crashreporter.h
+++ b/toolkit/crashreporter/client/crashreporter.h
@@ -34,21 +34,17 @@ std::string WideToUTF8(const std::wstrin
 
 #  define UI_SNPRINTF snprintf
 #  define UI_DIR_SEPARATOR "/"
 
 #endif
 
 #define UI_CRASH_REPORTER_FILENAME "crashreporter"
 #define UI_MINIDUMP_ANALYZER_FILENAME "minidump-analyzer"
-#ifndef XP_MACOSX
-#  define UI_PING_SENDER_FILENAME "pingsender"
-#else
-#  define UI_PING_SENDER_FILENAME "../../../pingsender"
-#endif
+#define UI_PING_SENDER_FILENAME "pingsender"
 
 typedef std::map<std::string, std::string> StringTable;
 
 #define ST_CRASHREPORTERTITLE "CrashReporterTitle"
 #define ST_CRASHREPORTERVENDORTITLE "CrashReporterVendorTitle"
 #define ST_CRASHREPORTERERROR "CrashReporterErrorText"
 #define ST_CRASHREPORTERPRODUCTERROR "CrashReporterProductErrorText2"
 #define ST_CRASHREPORTERHEADER "CrashReporterSorry"
--- a/toolkit/crashreporter/minidump-analyzer/moz.build
+++ b/toolkit/crashreporter/minidump-analyzer/moz.build
@@ -1,19 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 if CONFIG['OS_TARGET'] != 'Android':
-    GeckoProgram(name='minidump-analyzer', linkage=None)
-
-    if CONFIG['OS_TARGET'] == 'Darwin':
-        DIST_SUBDIR = 'crashreporter.app/Contents/MacOS'
+    GeckoProgram('minidump-analyzer', linkage=None)
 
     if CONFIG['OS_TARGET'] == 'WINNT':
         DEFINES['UNICODE'] = True
         DEFINES['_UNICODE'] = True
 
         if CONFIG['CPU_ARCH'] == 'x86_64':
             UNIFIED_SOURCES += [
                 'MozStackFrameSymbolizer.cpp',