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•3 years ago
|
||
This patch does the following:
- General cleanup:
- More explicit restrictions of how/when the various constructors are available.
InitializeSecurity
is madestatic
, since it doesn't really manipulate instance variables.- We move some logic for resolving
CoInitializeEx
flags intoGetDesiredApartmentType
. - We also try to set
COINIT_SPEED_OVER_MEMORY
for 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.PostInit
is a static method that
is invoked once theProcessRuntime
is 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 eliminateCoInitializeEx
calls 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•3 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•3 years ago
|
||
- We make
EnsureMTA
's default constructorprivate
, andProcessRuntime
a friend.
ProcessRuntime
calls this to eagerly create the MTA. - The default constructor uses the new-ish
CoIncrementMTAUsage
to 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•3 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•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=2819a29887b21656501b29aafd65ac0f0da0a28e
Assignee | ||
Comment 6•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=01425f0b9964349ae0a7b411c88bf04ace121224
Assignee | ||
Comment 7•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=66a4065163c4063a7d5c326fbcbdf9d6139668cd
Assignee | ||
Comment 8•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=c122b2ca85bc0585185f7fb6d527fcd991071ae7
Assignee | ||
Comment 9•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=e84649874fbf3996dd788217b2cad03ecf8ef888
Assignee | ||
Comment 10•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=1d91f79f2a54b8a5dd27cd23da9db3778049b299
Assignee | ||
Comment 11•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=305c68efc25fcb429899c719baf3b49455ec808e
Comment 12•3 years ago
|
||
Pushed by aklotz@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fb4829011104 Part 1 - Change mscom::ProcessRuntime to ensure MTA creation during startup; r=Jamie https://hg.mozilla.org/integration/autoland/rev/f72b810472fd Part 2 - Update Launcher Process with mscom::ProcessRuntime changes; r=Jamie https://hg.mozilla.org/integration/autoland/rev/e1b37839487b Part 3 - Add eager MTA creation to mscom::EnsureMTA; r=Jamie https://hg.mozilla.org/integration/autoland/rev/fa23f9293250 Part 4 - Build fixes to reflect EnsureMTA changes; r=Jamie
Comment 13•3 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•3 years ago
|
Comment 14•3 years ago
|
||
Pushed by aklotz@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/49406bdac5ec Part 1 - Change mscom::ProcessRuntime to ensure MTA creation during startup; r=Jamie https://hg.mozilla.org/integration/autoland/rev/55586d8f7bf4 Part 2 - Update Launcher Process with mscom::ProcessRuntime changes; r=Jamie https://hg.mozilla.org/integration/autoland/rev/fd52d202d10b Part 3 - Add eager MTA creation to mscom::EnsureMTA; r=Jamie https://hg.mozilla.org/integration/autoland/rev/7cb0db27236c Part 4 - Build fixes to reflect EnsureMTA changes; r=Jamie
Comment 15•3 years ago
|
||
Backout by mlaza@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d00ac5eba3b0 Backed out 4 changesets for causing bc failures in ClearOnShutdown.cpp.
Comment 16•3 years ago
|
||
Backed out 4 changesets (Bug 1707954) for causing bc failures in ClearOnShutdown.cpp.
Comment 17•3 years ago
•
|
||
There are also xpcshell failures on test_launch_without_hang.js
Assignee | ||
Comment 18•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=1a84dba8da886f0a6d5207c621a8db497d27018e
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 19•3 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f4cd760ae2bea82e9ed26f617255f8b924344b00
Comment 20•3 years ago
|
||
Pushed by aklotz@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d1c08a9fc957 Part 1 - Change mscom::ProcessRuntime to ensure MTA creation during startup; r=Jamie https://hg.mozilla.org/integration/autoland/rev/c419279fff66 Part 2 - Update Launcher Process with mscom::ProcessRuntime changes; r=Jamie https://hg.mozilla.org/integration/autoland/rev/4e833faa1996 Part 3 - Add eager MTA creation to mscom::EnsureMTA; r=Jamie https://hg.mozilla.org/integration/autoland/rev/224d902faaf8 Part 4 - Build fixes to reflect EnsureMTA changes; r=Jamie
Comment 21•3 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
•