Closed Bug 614229 Opened 10 years ago Closed 10 years ago

Recursive layout-module initialization in content processes of Firefox

Categories

(Core :: Networking: HTTP, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: benjamin, Assigned: benjamin)

References

Details

Attachments

(1 file)

When trying to use a content process with Firefox, the content process aborts early in startup with this stack:

###!!! ASSERTION: Recursive layout module initialization: 'Error', file ../../../src/layout/build/nsLayoutModule.cpp, line 377
Initialize() (/builds/mozilla-central/ff-debug/layout/build/../../../src/layout/build/nsLayoutModule.cpp:378)
nsComponentManagerImpl::KnownModule::Load() (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:961)
nsFactoryEntry::GetFactory() (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1936)
nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1299)
nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1664)
nsGetServiceFromCategory::operator()(nsID const&, void**) const (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:219)
nsCOMPtr<mozilla::ModuleLoader>::assign_from_helper(nsCOMPtr_helper const&, nsID const&) (/builds/mozilla-central/ff-debug/xpcom/components/../../dist/include/nsCOMPtr.h:1272)
nsCOMPtr<mozilla::ModuleLoader>::operator=(nsCOMPtr_helper const&) (/builds/mozilla-central/ff-debug/xpcom/components/../../dist/include/nsCOMPtr.h:731)
nsComponentManagerImpl::LoaderForExtension(nsACString_internal const&) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1692)
nsComponentManagerImpl::KnownModule::EnsureLoader() (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:935)
nsComponentManagerImpl::KnownModule::Load() (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:946)
nsFactoryEntry::GetFactory() (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1936)
nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1299)
nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1664)
CallGetService(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/glue/../../../src/xpcom/glue/nsComponentManagerUtils.cpp:69)
nsGetServiceByContractIDWithError::operator()(nsID const&, void**) const (/builds/mozilla-central/ff-debug/xpcom/glue/../../../src/xpcom/glue/nsComponentManagerUtils.cpp:288)
nsCOMPtr<nsIPrivateBrowsingService>::assign_from_gs_contractid_with_error(nsGetServiceByContractIDWithError const&, nsID const&) (/builds/mozilla-central/ff-debug/browser/components/privatebrowsing/src/../../../../dist/include/nsCOMPtr.h:1262)
nsCOMPtr<nsIPrivateBrowsingService>::operator=(nsGetServiceByContractIDWithError const&) (/builds/mozilla-central/ff-debug/browser/components/privatebrowsing/src/../../../../dist/include/nsCOMPtr.h:722)
nsPrivateBrowsingServiceWrapper::Init() (/builds/mozilla-central/ff-debug/browser/components/privatebrowsing/src/../../../../../src/browser/components/privatebrowsing/src/nsPrivateBrowsingServiceWrapper.cpp:59)
nsPrivateBrowsingServiceWrapperConstructor (/builds/mozilla-central/ff-debug/browser/components/build/../../../../src/browser/components/build/nsModule.cpp:121)
mozilla::GenericFactory::CreateInstance(nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/build/GenericFactory.cpp:49)
nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1303)
nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1664)
CallGetService(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/build/nsComponentManagerUtils.cpp:95)
nsGetServiceByContractID::operator()(nsID const&, void**) const (/builds/mozilla-central/ff-debug/xpcom/build/nsComponentManagerUtils.cpp:278)
nsCOMPtr<nsIPrivateBrowsingService>::assign_from_gs_contractid(nsGetServiceByContractID, nsID const&) (/builds/mozilla-central/ff-debug/widget/src/xpwidgets/../../../dist/include/nsCOMPtr.h:1252)
nsCOMPtr (/builds/mozilla-central/ff-debug/toolkit/components/places/src/../../../../dist/include/nsCOMPtr.h:628)
nsHttpHandler::Init() (/builds/mozilla-central/ff-debug/netwerk/protocol/http/../../../../src/netwerk/protocol/http/nsHttpHandler.cpp:258)
nsHttpHandlerConstructor (/builds/mozilla-central/ff-debug/netwerk/build/../../../src/netwerk/build/nsNetModule.cpp:247)
mozilla::GenericFactory::CreateInstance(nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/build/GenericFactory.cpp:49)
nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1303)
nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1664)
CallGetService(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/build/nsComponentManagerUtils.cpp:95)
nsGetServiceByContractID::operator()(nsID const&, void**) const (/builds/mozilla-central/ff-debug/xpcom/build/nsComponentManagerUtils.cpp:278)
nsCOMPtr<nsIProtocolHandler>::assign_from_gs_contractid(nsGetServiceByContractID, nsID const&) (/builds/mozilla-central/ff-debug/modules/plugin/base/src/../../../../dist/include/nsCOMPtr.h:1252)
nsCOMPtr (/builds/mozilla-central/ff-debug/modules/plugin/base/src/../../../../dist/include/nsCOMPtr.h:628)
nsHttpsHandler::Init() (/builds/mozilla-central/ff-debug/netwerk/protocol/http/../../../../src/netwerk/protocol/http/nsHttpHandler.cpp:1640)
nsHttpsHandlerConstructor (/builds/mozilla-central/ff-debug/netwerk/build/../../../src/netwerk/build/nsNetModule.cpp:248)
mozilla::GenericFactory::CreateInstance(nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/build/GenericFactory.cpp:49)
nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1303)
nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1664)
CallGetService(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/build/nsComponentManagerUtils.cpp:95)
unsigned int CallGetService<nsIProtocolHandler>(char const*, nsIProtocolHandler**) (/builds/mozilla-central/ff-debug/netwerk/protocol/ftp/../../../dist/include/nsServiceManagerUtils.h:131)
nsIOService::GetProtocolHandler(char const*, nsIProtocolHandler**) (/builds/mozilla-central/ff-debug/netwerk/base/src/../../../../src/netwerk/base/src/nsIOService.cpp:434)
nsIOService::NewURI(nsACString_internal const&, char const*, nsIURI*, nsIURI**) (/builds/mozilla-central/ff-debug/netwerk/base/src/../../../../src/netwerk/base/src/nsIOService.cpp:535)
NS_NewURI(nsIURI**, nsACString_internal const&, char const*, nsIURI*, nsIIOService*) (/builds/mozilla-central/ff-debug/chrome/src/../../dist/include/nsNetUtil.h:172)
nsPrincipal::InitFromPersistent(char const*, nsCString const&, nsCString const&, nsACString_internal const&, char const*, char const*, nsISupports*, int, int) (/builds/mozilla-central/ff-debug/caps/src/../../../src/caps/src/nsPrincipal.cpp:870)
nsScriptSecurityManager::InitPrincipals(unsigned int, char const**) (/builds/mozilla-central/ff-debug/caps/src/../../../src/caps/src/nsScriptSecurityManager.cpp:3934)
nsScriptSecurityManager::InitPrefs() (/builds/mozilla-central/ff-debug/caps/src/../../../src/caps/src/nsScriptSecurityManager.cpp:4015)
nsScriptSecurityManager::Init() (/builds/mozilla-central/ff-debug/caps/src/../../../src/caps/src/nsScriptSecurityManager.cpp:3375)
nsScriptSecurityManager::GetScriptSecurityManager() (/builds/mozilla-central/ff-debug/caps/src/../../../src/caps/src/nsScriptSecurityManager.cpp:3458)
nsContentUtils::Init() (/builds/mozilla-central/ff-debug/content/base/src/../../../../src/content/base/src/nsContentUtils.cpp:450)
nsLayoutStatics::Initialize() (/builds/mozilla-central/ff-debug/layout/build/../../../src/layout/build/nsLayoutStatics.cpp:168)
Initialize() (/builds/mozilla-central/ff-debug/layout/build/../../../src/layout/build/nsLayoutModule.cpp:392)
nsComponentManagerImpl::KnownModule::Load() (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:961)
nsFactoryEntry::GetFactory() (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1936)
nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1299)
nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/components/../../../src/xpcom/components/nsComponentManager.cpp:1664)
CallGetService(char const*, nsID const&, void**) (/builds/mozilla-central/ff-debug/xpcom/build/nsComponentManagerUtils.cpp:95)
nsGetServiceByContractIDWithError::operator()(nsID const&, void**) const (/builds/mozilla-central/ff-debug/xpcom/build/nsComponentManagerUtils.cpp:288)
nsCOMPtr_base::assign_from_gs_contractid_with_error(nsGetServiceByContractIDWithError const&, nsID const&) (/builds/mozilla-central/ff-debug/xpcom/build/nsCOMPtr.cpp:141)
nsCOMPtr<nsISupports>::operator=(nsGetServiceByContractIDWithError const&) (/builds/mozilla-central/ff-debug/embedding/components/appstartup/src/../../../../dist/include/nsCOMPtr.h:1055)
nsAppStartupNotifier::Observe(nsISupports*, char const*, unsigned short const*) (/builds/mozilla-central/ff-debug/embedding/components/appstartup/src/../../../../../src/embedding/components/appstartup/src/nsAppStartupNotifier.cpp:100)
XRE_InitEmbedding2 (/builds/mozilla-central/ff-debug/toolkit/xre/../../../src/toolkit/xre/nsEmbedFunctions.cpp:203)
mozilla::ipc::ScopedXREEmbed::Start() (/builds/mozilla-central/ff-debug/ipc/glue/../../../src/ipc/glue/ScopedXREEmbed.cpp:112)
mozilla::dom::ContentProcess::Init() (/builds/mozilla-central/ff-debug/dom/ipc/../../../src/dom/ipc/ContentProcess.cpp:56)
XRE_InitChildProcess (/builds/mozilla-central/ff-debug/toolkit/xre/../../../src/toolkit/xre/nsEmbedFunctions.cpp:500)
main (/builds/mozilla-central/ff-debug/ipc/app/../../../src/ipc/app/MozillaRuntimeMain.cpp:80)
__libc_start_main+0x000000FD  (/lib64/libc.so.6)
_start (jemalloc.c:0)

The basic recursion is layout module -> URI -> private browsing -> JS loader (xpconnect == layout module)

Although private browsing is going to need some work for content processes, this particular problem can be solved by making getting the private-browsing service from nsHttpHandler lazy.
Attachment #492634 - Flags: review?(honzab.moz)
I wonder if this is a recent regression. I'm not hitting this assertion with the tree I have from Nov 12.
Comment on attachment 492634 [details] [diff] [review]
Initialize private-browsing lazily from nsHttpHandler, rev. 1

Conceptually this patch seems to be ok for me.

>diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
>@@ -180,17 +180,17 @@ nsHttpHandler::nsHttpHandler()
>     , mRedirectionLimit(10)
>-    , mInPrivateBrowsingMode(PR_FALSE)
>+    , mInPrivateBrowsingMode(PRIVATE_BROWSING_UNKNOWN)

Please also reorder correctly to prevent warnings.

>+PRBool
>+nsHttpHandler::InPrivateBrowsingMode()
>+        if (!pbs)
>+            return PRIVATE_BROWSING_OFF;

Hmm.. as an opt, could we also set mInPrivateBrowsingMode to PRIVATE_BROWSING_OFF here?  Or is there a chance that PB service may get registered later?


r=honzab with these changes.
Attachment #492634 - Flags: review?(honzab.moz) → review+
(In reply to comment #3)
> >+PRBool
> >+nsHttpHandler::InPrivateBrowsingMode()
> >+        if (!pbs)
> >+            return PRIVATE_BROWSING_OFF;
> 
> Hmm.. as an opt, could we also set mInPrivateBrowsingMode to
> PRIVATE_BROWSING_OFF here?  Or is there a chance that PB service may get
> registered later?

No, the private browsing service, if not available, cannot suddently become available.  So that optimization would be safe.
Comment on attachment 492634 [details] [diff] [review]
Initialize private-browsing lazily from nsHttpHandler, rev. 1

>+PRBool
>+nsHttpHandler::InPrivateBrowsingMode()
>+{
>+    if (PRIVATE_BROWSING_UNKNOWN == mInPrivateBrowsingMode) {
>+        // figure out if we're starting in private browsing mode
>+        nsCOMPtr<nsIPrivateBrowsingService> pbs =
>+            do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
>+        if (!pbs)
>+            return PRIVATE_BROWSING_OFF;
>+
>+        PRBool p = PR_FALSE;
>+        pbs->GetPrivateBrowsingEnabled(&p);
>+        mInPrivateBrowsingMode = p ? PRIVATE_BROWSING_ON : PRIVATE_BROWSING_OFF;
>+    }
>+    return (PRBool) mInPrivateBrowsingMode;

Nit: please use mInPrivateBrowsingMode == PRIVATE_BROWSING_ON instead.

r=me with this and honza's comments.
Attachment #492634 - Flags: review?(ehsan) → review+
The private browsing service *can* become available later if 1) an extension implements it or 2) if an HTTP URL is created during XPCOM registration. Both of these are possible, and I'd like to keep the unoptimized version.
http://hg.mozilla.org/mozilla-central/rev/0ec2e68a8677
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
(In reply to comment #6)
> The private browsing service *can* become available later if 1) an extension
> implements it or 2) if an HTTP URL is created during XPCOM registration. Both
> of these are possible, and I'd like to keep the unoptimized version.

Hmm, you're right.  But on the other hand, a lot of things will break this way, but I guess it's not an issue that we should worry about right now.

Thanks for your patch!
Duplicate of this bug: 617146
You need to log in before you can comment on or make changes to this bug.