gecko-dev/toolkit
Gabriele Svelto 06a240a0f3 Bug 1628399 - Make sure that the main process can't access a crash report before it's fully populated r=KrisWright
In bug 1614933 we changed the order in which the crash annotations are sent
from a crashed content process to the main process in order to prevent a
deadlock that would arise if the child process would block writing into the
pipe used to sent the annotations.

This unfortunately introduced a race that I had missed. Here's the sequence of
event when generating a crash in the child process:

1) The child process enters the exception handler
2) It requests a dump from the main process and wait
3) Once the dump is written, the child process wakes up again and writes out
   the crash annotations
4) The child process quits

One the main process side it looks like this:

1) The crash generation thread receives a request to generate a dump
2) The dump is written out, the crash generation thread notifies the content
   process that it can resume execution. During this step the finished
   minidump is recorded in the `OnChildProcessDumpRequested()` callback.
3) The crash generation thread reads the crash annotations sent by the content
   process and finalizes the crash report
4) The main process grabs the finalized crash report

The key issue here is that the main process in step 4 is woken up when the
content process dies. Notice how there's no synchronization between the crash
generation thread and the main thread in the main process: if the crash
generation thread takes too long reading the crash annotations the main thread
might see an incomplete or missing crash report; that's because the event that
wakes it up - the content process ending execution - can happen in parallel
with step 3.

This is an issue that was accidentally introduced in Windows by bug 1614933
but was already present in both Linux and macOS. It was just very unlikely to
happen.

This patch fixes the issue by splitting step 3 in the main process in two
different stages: in the main process we grab the generated minidump in
`OnChildProcessDumpRequested()`, Breakpad then unblocks the child process and
we read the annotations in `OnChildProcessDumpWritten()`. We grab the
`dumpMapLock` Mutex in the latter and release it in the former to ensure that
the main process will have to wait for the crash report to be finalized when
`TakeCrashedChildProcess()` is called. This might appear somewhat confusing
and even causes debug builds to spit a harmless warning (we don't want Mutexes
to be taken and released from different scopes if we can help it).

To implement the above behavior in Breakpad a new callback was introduced in
Windows, an existing one was used under macOS and an unused one was used under
Linux. This accounts for the different way in which minidumps are generated on
the three platforms.

Differential Revision: https://phabricator.services.mozilla.com/D74496
2020-05-18 20:34:48 +00:00
..
actors Bug 1636968 - Stop focusing the view-source content window on load. r=Honza 2020-05-18 07:23:54 +00:00
components Bug 1629604 - Fixed phrase not found in visible <script> and added a test for visible <script>. r=emilio 2020-05-18 21:28:46 +00:00
content Bug 1627711 - Remove incremental GC information from about:support r=Gijs,fluent-reviewers 2020-05-18 16:09:45 +00:00
crashreporter Bug 1628399 - Make sure that the main process can't access a crash report before it's fully populated r=KrisWright 2020-05-18 20:34:48 +00:00
docs Bug 1622836 - Added documentation for nsIPromptService. r=johannh DONTBUILD 2020-04-22 10:28:04 +00:00
library Bug 1631630 p2 - Implement FxAccounts rust-bridge. r=lina,rfkelly 2020-05-16 01:07:31 +00:00
locales Bug 1627711 - Remove incremental GC information from about:support r=Gijs,fluent-reviewers 2020-05-18 16:09:45 +00:00
modules Bug 1627711 - Remove incremental GC information from about:support r=Gijs,fluent-reviewers 2020-05-18 16:09:45 +00:00
mozapps Backed out 6 changesets (bug 1002724) for failing in browser_fall_back_to_https.js CLOSED TREE 2020-05-18 19:22:19 +03:00
pluginproblem
profile Bug 1536556 - Replace raw thrown Cr.ERRORs with Components.Exception. r=mossop,remote-protocol-reviewers,marionette-reviewers,whimboo,necko-reviewers,geckoview-reviewers,valentin,agi 2020-05-05 17:41:36 +00:00
system Bug 1196151 - use BrowsingContext for external helper app handling of protocols, r=mattwoodrow 2020-05-11 13:13:03 +00:00
themes Bug 1636998 - Make ::-moz-focus-outer a no-op, and remove it on Nightly. r=jwatt 2020-05-18 10:54:16 +00:00
xre Bug 1637452: Part 6 - Fix JNI includes in toolkit/xre; r=froydnj 2020-05-15 17:04:22 +00:00
.eslintrc.js Bug 1622328 - add license info to all eslintrc files r=Standard8,webcompat-reviewers,miketaylr 2020-03-19 13:47:51 +00:00
l10n-registry.manifest
moz.build Bug 1580870 - Move toolkit/forgetaboutsite to toolkit/components/forgetaboutsite r=johannh 2020-04-21 11:27:30 +00:00
moz.configure Bug 1638193 - Remove build system support for iOS. r=nalexander 2020-05-15 03:56:16 +00:00
toolkit.mozbuild