Make ProcessRuntime guarantee that all non-main threads are implicit members of the MTA
Categories
(Core :: IPC: MSCOM, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox91 | --- | fixed |
People
(Reporter: bugzilla, Assigned: bugzilla)
References
Details
Attachments
(4 files)
I want to make it so that we can eventually ban CoInitialize* and OleInitialize outside of ProcessRuntime. Let's ensure that we always have the MTA up and running, so that all threads that do not explicitly declare their apartment membership are implicit members of the MTA.
| Assignee | ||
Comment 1•4 years ago
|
||
This patch does the following:
- General cleanup:
- More explicit restrictions of how/when the various constructors are available.
InitializeSecurityis madestatic, since it doesn't really manipulate instance variables.- We move some logic for resolving
CoInitializeExflags intoGetDesiredApartmentType. - We also try to set
COINIT_SPEED_OVER_MEMORYfor 64-bit builds with more than 4GB of RAM.
I'm not sure how useful that is, but I thought it might be interesting to try.
- Addition of
PostInit:- This doesn't do anything at the moment, but since I'm already making a bunch
of changes, I wanted to add this too.PostInitis a static method that
is invoked once theProcessRuntimeis finished initializing, and, when
present, the sandbox is fully enabled.
- This doesn't do anything at the moment, but since I'm already making a bunch
- We call
EnsureMTA's default constructor to eagerly bring up the MTA. This
causes all background threads to implicitly become members of the MTA, which
means that we can eliminateCoInitializeExcalls throughout our codebase,
since they're slow and most developers do not have a clear understanding of
what those functions actually do.- This also simplifies the COM initialization in sandboxed content processes
with Win32K lockdown, since if our main thread is in the implicit MTA, we
can immediately initialize ourselves without needing to punt that work
over to the persistent MTA thread.
- This also simplifies the COM initialization in sandboxed content processes
| Assignee | ||
Comment 2•4 years ago
|
||
Given the changes in part 1, we must now use the ProcessCategory variant of
ProcessRuntime's constructors.
Depends on D113560
| Assignee | ||
Comment 3•4 years ago
|
||
- We make
EnsureMTA's default constructorprivate, andProcessRuntimea friend.
ProcessRuntimecalls this to eagerly create the MTA. - The default constructor uses the new-ish
CoIncrementMTAUsageto create the
MTA without requiring a dedicated thread (when available). Otherwise we
fall back to the traditional method. In the latter case, we synchronously
wait for the initialization to complete so that we are guaranteed to have
an MTA when we return. - Some minor refactoring to make it easier to do the sync wait in the
default constructor. I also renamed a couple of things just to make them
more clear.
Depends on D113561
| Assignee | ||
Comment 4•4 years ago
|
||
Now that we always have an MTA active, we don't need to explicitly try to
start it anymore. These locations in our source were doing so, which is now
not only redundant, but fails (since EnsureMTA's default constructor is now
private).
Depends on D113562
| Assignee | ||
Comment 5•4 years ago
|
||
| Assignee | ||
Comment 6•4 years ago
|
||
| Assignee | ||
Comment 7•4 years ago
|
||
| Assignee | ||
Comment 8•4 years ago
|
||
| Assignee | ||
Comment 9•4 years ago
|
||
| Assignee | ||
Comment 10•4 years ago
|
||
| Assignee | ||
Comment 11•4 years ago
|
||
Comment 12•4 years ago
|
||
Comment 13•4 years ago
|
||
Backed out 4 changesets (Bug 1707954) for causing bustages in rules.mk CLOSED TREE
Log: https://treeherder.mozilla.org/logviewer?job_id=342308870&repo=autoland&lineNumber=15157
Backout: https://hg.mozilla.org/integration/autoland/rev/4b3932f9c4f5d9572da2f0232375474133191500
| Assignee | ||
Updated•4 years ago
|
Comment 14•4 years ago
|
||
Comment 15•4 years ago
|
||
Comment 16•4 years ago
|
||
Backed out 4 changesets (Bug 1707954) for causing bc failures in ClearOnShutdown.cpp.
Comment 17•4 years ago
•
|
||
There are also xpcshell failures on test_launch_without_hang.js
| Assignee | ||
Comment 18•4 years ago
|
||
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 19•4 years ago
|
||
Comment 20•4 years ago
|
||
Comment 21•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/d1c08a9fc957
https://hg.mozilla.org/mozilla-central/rev/c419279fff66
https://hg.mozilla.org/mozilla-central/rev/4e833faa1996
https://hg.mozilla.org/mozilla-central/rev/224d902faaf8
Description
•