Bug 1353168 - Add a crash annotation to distinguish between web, file and extension content processes; r?bsmedberg draft
authorGabriele Svelto <gsvelto@mozilla.com>
Thu, 01 Jun 2017 11:16:11 +0200
changeset 587656 e40174fac7f78b02948679d00af7b327fb79f208
parent 587503 bdb2387396b4a74dfefb7c983733eed3625e906a
child 631331 82024e281893e4fb4714b1970ecd4b7a45c13f34
push id61773
push usergsvelto@mozilla.com
push dateThu, 01 Jun 2017 13:06:27 +0000
Bug 1353168 - Add a crash annotation to distinguish between web, file and extension content processes; r?bsmedberg This adds the RemoteType annotation to a content crash report so that we can distinguish between content processes that crashed while running remote, local or extension code. The annotation is passed along the others to Socorro by the crashreporter and is also whitelisted for inclusion in the crash ping. MozReview-Commit-ID: 4avo0IWfMGf
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1498,16 +1498,18 @@ ContentChild::RecvSetProcessSandbox(cons
     sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
 #if defined(XP_LINUX) && !defined(OS_ANDROID)
   nsAutoCString flagsString;
     NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
 #endif /* XP_LINUX && !OS_ANDROID */
+  CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("RemoteType"),
+                                     NS_ConvertUTF16toUTF8(GetRemoteType()));
   return IPC_OK();
 ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL,
--- a/toolkit/components/crashes/CrashManager.jsm
+++ b/toolkit/components/crashes/CrashManager.jsm
@@ -225,16 +225,17 @@ this.CrashManager.prototype = Object.fre
   // A whitelist of crash annotations which do not contain sensitive data
   // and are saved in the crash record and sent with Firefox Health Report.
+    "RemoteType",
     // The following entries are not normal annotations that can be found in
     // the .extra file but are included in the crash record/FHR:
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
+++ b/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
@@ -477,18 +477,20 @@ add_task(async function test_child_proce
   let ac = new TelemetryArchiveTesting.Checker();
   await ac.promiseInit();
   // Add a child-process crash for each allowed process type.
   for (let p of EXPECTED_PROCESSES) {
     // Generate a ping.
+    const remoteType = (p === m.PROCESS_TYPE_CONTENT) ? "web" : undefined;
     let id = await m.createDummyDump();
     await m.addCrash(p, m.CRASH_TYPE_CRASH, id, DUMMY_DATE, {
+      RemoteType: remoteType,
       StackTraces: stackTraces,
       MinidumpSha256Hash: sha256Hash,
       ThisShouldNot: "end-up-in-the-ping"
     await m._pingPromise;
     let found = await ac.promiseFindPing("crash", [
       [["payload", "crashId"], id],
@@ -500,16 +502,18 @@ add_task(async function test_child_proce
     let hoursOnly = new Date(DUMMY_DATE);
     Assert.equal(new Date(found.payload.crashTime).getTime(), hoursOnly.getTime());
     Assert.equal(found.payload.metadata.ThisShouldNot, undefined,
                  "Non-whitelisted fields should be filtered out");
+    Assert.equal(found.payload.metadata.RemoteType, remoteType,
+                 "RemoteType should be whitelisted for content crashes");
   // Check that we don't generate a crash ping for invalid/unexpected process
   // types.
   for (let p of UNEXPECTED_PROCESSES) {
     let id = await m.createDummyDump();
     await m.addCrash(p, m.CRASH_TYPE_CRASH, id, DUMMY_DATE, {
       StackTraces: stackTraces,
--- a/toolkit/components/telemetry/docs/data/crash-ping.rst
+++ b/toolkit/components/telemetry/docs/data/crash-ping.rst
@@ -51,16 +51,17 @@ Structure:
           BlockedDllList: <list>, // Windows-only, see WindowsDllBlocklist.cpp for details
           BlocklistInitFailed: 1, // Windows-only, present only if the DLL blocklist initialization failed
           CrashTime: <time>, // Seconds since the Epoch
           ContainsMemoryReport: 1, // Optional
           EventLoopNestingLevel: <levels>, // Optional, present only if >0
           IsGarbageCollecting: 1, // Optional, present only if set to 1
           MozCrashReason: <reason>, // Optional, contains the string passed to MOZ_CRASH()
           OOMAllocationSize: <size>, // Size of the allocation that caused an OOM
+          RemoteType: <type>, // Optional, type of content process, see below for a list of types
           SecondsSinceLastCrash: <duration>, // Seconds elapsed since the last crash occurred
           SystemMemoryUsePercentage: <percentage>, // Windows-only, percent of memory in use
           TelemetrySessionId: <id>, // Active telemetry session ID when the crash was recorded
           TextureUsage: <usage>, // Optional, usage of texture memory in bytes
           TotalPageFile: <size>, // Windows-only, paging file in use
           TotalPhysicalMemory: <size>, // Windows-only, physical memory in use
           TotalVirtualMemory: <size>, // Windows-only, virtual memory in use
           UptimeTS: <duration>, // Seconds since Firefox was started
@@ -87,16 +88,33 @@ are sent only for the ones below:
 | main          | Main process, also known as the browser process   |
 | content       | Content process                                   |
 | gpu           | GPU process                                       |
+Remote Process Types
+The optional ``remoteType`` field contains the type of the content process that
+crashed. As such it is present only if ``processType`` contains the ``content``
+value. The following content process types are currently defined:
+| Type      | Description                                            |
+| web       | The content process was running code from a web page   |
+| file      | The content process was running code from a local file |
+| extension | The content process was running code from an extension |
 Stack Traces
 The crash ping may contain a ``stackTraces`` field which has been populated
 with stack traces for all threads in the crashed process. The format of this
 field is similar to the one used by Socorro for representing a crash. The main
 differences are that redundant fields are not stored and that the module a
 frame belongs to is referenced by index in the module array rather than by its
--- a/toolkit/crashreporter/client/ping.cpp
+++ b/toolkit/crashreporter/client/ping.cpp
@@ -132,16 +132,17 @@ CreateMetadataNode(StringTable& strings)
+    "RemoteType",