зеркало из https://github.com/mozilla/gecko-dev.git
e48051a0ac
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 |
||
---|---|---|
.. | ||
base | ||
build | ||
components | ||
doc | ||
ds | ||
glue | ||
idl-parser | ||
io | ||
libxpt/xptcall | ||
reflect | ||
rust | ||
string | ||
system | ||
tests | ||
threads | ||
windbgdlg | ||
xpidl | ||
moz.build | ||
xpcom-config.h.in |