Bug 1527803: Make sure debug service is instantiated before starting Watchdog thread. r=erahm

The watchdog thread's stack is intentionally kept as small as possible, since
the work that it does is trivial and should not require much stack space.
One result of this is that the stack segment is generally too small to
instantiate a new service (and we really don't want to be instantiating
services on it anyway).

The debug service is generally instantiated before the watchdog thread tries
to touch it, but this isn't guaranteed (and, in particular, it often isn't for
xpcshell runs on some noopt debug builds). Instantiating it before starting
the watchdog thread solves this problem.

Differential Revision: https://phabricator.services.mozilla.com/D20869

--HG--
extra : rebase_source : 2f9c3e412a7ad9a0b6f84c61907e4a7508f3b18c
This commit is contained in:
Kris Maglione 2019-02-22 13:03:06 -08:00
Родитель c839074621
Коммит e97c8bb395
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -143,6 +143,16 @@ class Watchdog {
MOZ_CRASH("PR_NewCondVar failed.");
}
{
// Make sure the debug service is instantiated before we create the
// watchdog thread, since we intentionally try to keep the thread's stack
// segment as small as possible. It isn't always large enough to
// instantiate a new service, and even when it is, we don't want fault in
// extra pages if we can avoid it.
nsCOMPtr<nsIDebug2> dbg = do_GetService("@mozilla.org/xpcom/debug;1");
Unused << dbg;
}
{
AutoLockWatchdog lock(this);