Bug 1545381 - be more defensive in nsAppShellSingleton; r=erahm

We're seeing crashes in bug 1545381 in appshell shutdown, which appear
to point to appshell initialization somehow falling over non-obviously.
Appshell initialization should basically never fail, so let's complain
loudly if that ever happens.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-07-22 20:52:35 +00:00
parent 24c0d0e47d
commit 2257f3e1ae

View File

@ -38,12 +38,13 @@ static nsresult nsAppShellInit() {
if (!sAppShell) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(sAppShell);
nsresult rv;
rv = static_cast<nsAppShell*>(sAppShell)->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(sAppShell);
return rv;
}
nsresult rv = static_cast<nsAppShell*>(sAppShell)->Init();
// If we somehow failed to initialize the appshell, it's extremely likely
// that we are sufficiently hosed that continuing on is just going to lead
// to bad things later. By crashing early here, the crash report will
// potentially contain a little more insight into what's going wrong than
// if we waited for a crash further down the line. See also bug 1545381.
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
return NS_OK;
}