gecko-dev/xpcom/components
Dana Keeler e48051a0ac Bug 1634065 - remove the nested event loop in nsComponentManagerImpl::GetServiceLocked r=nika
If the implementation of an XPCOM service constructor involves dispatching an
event to another thread and blocking the current thread on that event, a
deadlock can occur if the target thread is also attempting to obtain that
service at the same time.
For instance, say nsIExampleService needs to be constructed on the main thread,
but some code in thread T is attempting to get a handle on it. Suppose the
implementation checks which thread it's running on and dispatches a synchronous
event to the main thread to do the actual construction work in the case that it
is not on the main thread. Further suppose that before that event is run, other
code on the main thread also attempts to get a handle on nsIExampleService. The
XPCOM service machinery sees that another thread is in the process of
constructing nsIExampleService, so it must wait for that to complete. However,
the thread that is attempting to do this construction is waiting for an event
to be run on the main thread. Thus, these two threads are deadlocked.
Before this patch, the XPCOM service machinery worked around this problem by
processing events on the second thread until it could proceed. However, this
caused a nested event loop, which is bad for stability because all guarantees
relating to when events will run are violated. In particular, this could cause
reentrency into the TLS implementation, which is not expected and has caused
intermittent crashes.
This patch removes the nested event loop in
nsComponentManagerImpl::GetServiceLocked in favor of not synchronously
dispatching events in XPCOM service constructors. One way to fix such
constructors is to move the event dispatch and blocking outside of the XPCOM
service machinery. See the other patch in this bug for an example.

Differential Revision: https://phabricator.services.mozilla.com/D92800
2020-11-17 16:30:06 +00:00
..
GenericFactory.cpp
GenericFactory.h
ManifestParser.cpp Bug 1650145 - Replace all value uses of Empty[C]String by 0-length _ns literals. r=froydnj,geckoview-reviewers,agi 2020-09-23 15:17:15 +00:00
ManifestParser.h
Module.h Update configs. IGNORE BROKEN CHANGESETS CLOSED TREE NO BUG a=release ba=release 2020-11-16 10:11:15 +00:00
ModuleUtils.h
StaticComponents.cpp.in Bug 1464542: Part 2 - Add infrastructure for defining named services exposed to JS. r=mccr8 2020-07-09 20:42:50 +00:00
StaticComponents.h Bug 1464542: Part 2 - Add infrastructure for defining named services exposed to JS. r=mccr8 2020-07-09 20:42:50 +00:00
components.conf Bug 1464542: Part 3b - Add existing Services.jsm registrations to the new services cache. r=mccr8,geckoview-reviewers,agi 2020-07-09 21:42:25 +00:00
gen_static_components.py Bug 1651774: Update mozilla/use-services rule for native Services implementation. r=Standard8 2020-11-06 18:58:33 +00:00
moz.build Bug 1651774: Update mozilla/use-services rule for native Services implementation. r=Standard8 2020-11-06 18:58:33 +00:00
nsCategoryCache.cpp
nsCategoryCache.h
nsCategoryManager.cpp Bug 1667915 - Separate marker category from marker options - r=gregtatum 2020-10-01 11:02:23 +00:00
nsCategoryManager.h
nsCategoryManagerUtils.h
nsComponentManager.cpp Bug 1634065 - remove the nested event loop in nsComponentManagerImpl::GetServiceLocked r=nika 2020-11-17 16:30:06 +00:00
nsComponentManager.h Bug 1634065 - remove the nested event loop in nsComponentManagerImpl::GetServiceLocked r=nika 2020-11-17 16:30:06 +00:00
nsComponentManagerUtils.cpp
nsComponentManagerUtils.h
nsICategoryManager.idl
nsIClassInfo.idl
nsIComponentManager.idl
nsIComponentRegistrar.idl
nsIFactory.idl
nsIModule.idl
nsIServiceManager.idl
nsServiceManagerUtils.h Bug 1666291 - Remove unused do_GetServiceFromCategory. r=xpcom-reviewers,nika 2020-09-21 16:39:26 +00:00