Commit Graph

321 Commits

Author SHA1 Message Date
Nika Layzell
df99325ea6 Bug 1895358 - Part 2: Handle ManagedContainer membership more centrally, r=ipc-reviewers,mccr8
This patch adjusts ManagedContainer to have a common base class, and exposes
methods for interacting with this base class from generic code on IProtocol.
This avoids the need for some specialized methods which were previously
required in order to manipulate the managed lists which allows the ordering to
be more precisely controlled in generic actor lifecycle methods.

Differential Revision: https://phabricator.services.mozilla.com/D209855
2024-05-15 20:36:28 +00:00
Nika Layzell
935075d7e4 Bug 1893150 - Handle actor id registration errors more explicitly, r=ipc-reviewers,mccr8
This is done by generating a new ID for the actor which can be successfully
registered, then explicitly tearing the actor down, improving the consistency
of error behaviour with other error cases during actor construction.

Differential Revision: https://phabricator.services.mozilla.com/D209064
2024-05-03 17:21:16 +00:00
Nika Layzell
af5b6a2c14 Bug 1724083 - Part 1: Rework ActorDestroy logic to be more resilient to nested event loops, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D198840
2024-04-22 17:31:06 +00:00
Nika Layzell
3943bcf519 Bug 1875528 - Part 7: Expose more BrowserParent members to the CC, r=smaug
It appears that the Element member may have been creating a reference
cycle passing through the new strong WindowGlobalParent::Manager()
reference.

This patch also removes an unused member from BrowserParent which
otherwise may have needed to be cycle-collected.

Differential Revision: https://phabricator.services.mozilla.com/D207170
2024-04-22 17:13:25 +00:00
Nika Layzell
656f3c5a4a Bug 1875528 - Part 6: Allow cycle-collecting the strong IPDL Manager reference, r=mccr8
There are a few IPDL actors which are cycle-collected, including `PBrowser`,
`PContent`, and `PWindowGlobal`.

This patch adds support for these actors to traverse and unlink the new strong
Manager() reference added by IPDL, allowing cycles containing these actors to
be properly unlinked and avoiding leaks.

Differential Revision: https://phabricator.services.mozilla.com/D198629
2024-04-22 17:13:24 +00:00
Nika Layzell
35816da309 Bug 1875528 - Part 1: Make IProtocol hold a strong reference to manager, r=ipc-reviewers,mccr8
This makes accessing `Manager()` on an IPDL protocol safer, and replaces the
previous ActorLifecycleProxy reference, which would only keep the manager alive
until IPDL drops its reference.

Unfortunately this introduces some leaks due to reference cycles, which will be
fixed in follow-up parts.

Differential Revision: https://phabricator.services.mozilla.com/D198624
2024-04-22 17:13:22 +00:00
Alex
a966534ce4 Bug 1729044 - Remove ipdl support for intr r=ipc-reviewers,nika
This removes intr support and updates some stale docs as well.

It's not immediately clear what code in MessageChannel can be removed,
though I expect some things could be simplified (there's just not much
alluding to intr/rpc/urgent).

Differential Revision: https://phabricator.services.mozilla.com/D204813
2024-03-20 14:28:15 +00:00
Iulian Moraru
74a8e4c335 Backed out changeset 8a9b63318958 (bug 1729044) for causing linux build bustages. CLOSED TREE 2024-03-19 04:58:49 +02:00
Alex
affaa233d1 Bug 1729044 - Remove ipdl support for intr r=ipc-reviewers,nika
This removes intr support and updates some stale docs as well.

It's not immediately clear what code in MessageChannel can be removed,
though I expect some things could be simplified (there's just not much
alluding to intr/rpc/urgent).

Differential Revision: https://phabricator.services.mozilla.com/D204813
2024-03-18 17:23:26 +00:00
Alex Franchuk
78f99130b0 Bug 1751995 - Add IPC_TEST_FAIL() and IPCResult::FailForTesting. r=ipc-reviewers,nika
The macro and function are meant to only be used in test circumstances, where we want the failure to
be returned. Normally in `DEBUG` builds the failure causes an immediate crash.

Differential Revision: https://phabricator.services.mozilla.com/D201158
2024-03-13 13:10:09 +00:00
Stanca Serban
5b1a9a8c0b Backed out 42 changesets (bug 1751995) for causing bp-nu failures in PTestDataStructuresSubChild.cpp. CLOSED TREE
Backed out changeset 5c26a10bf169 (bug 1751995)
Backed out changeset 02a074f96ccd (bug 1751995)
Backed out changeset f92cf21f54f5 (bug 1751995)
Backed out changeset e705865cf95f (bug 1751995)
Backed out changeset a3e4d1d2d709 (bug 1751995)
Backed out changeset 7384f5e7c454 (bug 1751995)
Backed out changeset d4ca13c89783 (bug 1751995)
Backed out changeset 96b164a065d4 (bug 1751995)
Backed out changeset c5a817f91355 (bug 1751995)
Backed out changeset 07dd40554527 (bug 1751995)
Backed out changeset ad9de08d7d4a (bug 1751995)
Backed out changeset 2d6b7a804db6 (bug 1751995)
Backed out changeset 52df9813a7a2 (bug 1751995)
Backed out changeset ca02c22179f1 (bug 1751995)
Backed out changeset 9543f729a08a (bug 1751995)
Backed out changeset b21677448d49 (bug 1751995)
Backed out changeset 66ca72b00da6 (bug 1751995)
Backed out changeset ece2f3b3e8b8 (bug 1751995)
Backed out changeset 913a95850424 (bug 1751995)
Backed out changeset 37aec76598c8 (bug 1751995)
Backed out changeset 64612f9a6dfe (bug 1751995)
Backed out changeset b3010b0f7b54 (bug 1751995)
Backed out changeset 534d39c27249 (bug 1751995)
Backed out changeset 4eade6ed42ae (bug 1751995)
Backed out changeset 88fee9cbf094 (bug 1751995)
Backed out changeset 943649ddc765 (bug 1751995)
Backed out changeset 6f5df39ac299 (bug 1751995)
Backed out changeset ee06381e3e1b (bug 1751995)
Backed out changeset 72caae243596 (bug 1751995)
Backed out changeset 9fce3d8543f4 (bug 1751995)
Backed out changeset a979771464dc (bug 1751995)
Backed out changeset 280122d631c0 (bug 1751995)
Backed out changeset 164df42eab65 (bug 1751995)
Backed out changeset 13f5be69033e (bug 1751995)
Backed out changeset 5e7f7bdd2743 (bug 1751995)
Backed out changeset 04d16fbe2bab (bug 1751995)
Backed out changeset 7184b5bfe2d2 (bug 1751995)
Backed out changeset bb0dda055124 (bug 1751995)
Backed out changeset fc3107b98ec6 (bug 1751995)
Backed out changeset 56233032dd1a (bug 1751995)
Backed out changeset c104ceccb708 (bug 1751995)
Backed out changeset 2412e5735361 (bug 1751995)
2024-03-12 18:17:27 +02:00
Alex Franchuk
e758cf03f0 Bug 1751995 - Add IPC_TEST_FAIL() and IPCResult::FailForTesting. r=ipc-reviewers,nika
The macro and function are meant to only be used in test circumstances, where we want the failure to
be returned. Normally in `DEBUG` builds the failure causes an immediate crash.

Differential Revision: https://phabricator.services.mozilla.com/D201158
2024-03-12 14:07:20 +00:00
Kelsey Gilbert
1456b448b4 Bug 1873812 - Remove Scoped.h usage in ipc/*. ipc-reviewers r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D198118
2024-02-06 18:57:44 +00:00
Nika Layzell
d51628d481 Bug 1873295 - Part 1: Relax Shmem DEBUG behaviour around actor destruction, r=ipc-reviewers,jld
Currently when in a DEBUG build, Shmem has a bunch of extra behaviour
and checks, which can occasionally make it more difficult to use. This
bug is to track removing some of the unnecessary checks being performed
which can make the type more complex to use safely.

Specifically, when the Shmem is destroyed at the actor level using
IPrococol::DeallocShmem or because the actor has died, in DEBUG builds
the memory mapping used by the Shmem is immediately mapped as
non-readable and non-writable. As this can happen at any time, this can
make using one of these Shmems from a different thread than the actor it
was originally bound to quite difficult. As an example, in bug 1812498,
special logic was added to VideoBridgeParent::OnChannelError to block
the actor's thread until off-thread uses of the Shmem were complete.

This behaviour was always debug-only, and is actually unnecessary. The
actual Shmem mapping is not managed by the actor, only the ability to
send it between processes, so it should be reasonable for one of these
objects to be used after the actor it was sent over is destroyed. This
patch does not change the behaviour of mapping the shared memory pages
as inaccessible for non-unsafe shmems while they are "owned" by another
process.

In the future, we may want to change the name "DeallocShmem" to be
something more representative of the true behaviour of the function
(which is to prevent further sending of the Shmem object over IPDL,
freeing IPDL's reference to the underlying shared memory segment).

Differential Revision: https://phabricator.services.mozilla.com/D197828
2024-02-05 18:43:43 +00:00
Emilio Cobos Álvarez
7cf73d5bb2 Bug 1877672 - Add missing std::forward in ProtocolUtils.h. r=nika
I think this should be harmless generally but seems the right thing to
do to me.

Differential Revision: https://phabricator.services.mozilla.com/D200348
2024-02-03 11:55:25 +00:00
Sebastian Hengst
ea96f9e2d8 Backed out changeset 3f73ffcf2a39 (bug 1877672) for build bustage in ipc/ProtocolUtils.h. CLOSED TREE 2024-02-02 10:54:37 +01:00
Emilio Cobos Álvarez
92852a6b70 Bug 1877672 - Add missing std::forward in ProtocolUtils.h. r=nika
I think this should be harmless generally but seems the right thing to
do to me.

Differential Revision: https://phabricator.services.mozilla.com/D200348
2024-02-02 09:16:58 +00:00
Stanca Serban
6980988721 Backed out 6 changesets (bug 1875528) for causing leakcheck failures. CLOSED TREE
Backed out changeset dcbbb7316940 (bug 1875528)
Backed out changeset a5c0564f9761 (bug 1875528)
Backed out changeset f3bc6e972f79 (bug 1875528)
Backed out changeset 535378dd79b0 (bug 1875528)
Backed out changeset 3cef14ed0f25 (bug 1875528)
Backed out changeset f0941fdbbabb (bug 1875528)
2024-01-25 01:26:46 +02:00
Nika Layzell
ba697a7ca5 Bug 1875528 - Part 6: Allow cycle-collecting the strong IPDL Manager reference, r=mccr8
There are a few IPDL actors which are cycle-collected, including `PBrowser`,
`PContent`, and `PWindowGlobal`.

This patch adds support for these actors to traverse and unlink the new strong
Manager() reference added by IPDL, allowing cycles containing these actors to
be properly unlinked and avoiding leaks.

Differential Revision: https://phabricator.services.mozilla.com/D198629
2024-01-24 20:54:42 +00:00
Nika Layzell
b94da40b23 Bug 1875528 - Part 1: Make IProtocol hold a strong reference to manager, r=ipc-reviewers,mccr8
This makes accessing `Manager()` on an IPDL protocol safer, and replaces the
previous ActorLifecycleProxy reference, which would only keep the manager alive
until IPDL drops its reference.

Unfortunately this introduces some leaks due to reference cycles, which will be
fixed in follow-up parts.

Differential Revision: https://phabricator.services.mozilla.com/D198624
2024-01-24 20:54:40 +00:00
Nika Layzell
c829b987d4 Bug 1874739 - Part 13: Introduce the IRefCountedProtocol type, r=ipc-reviewers,mccr8
This acts as a new class between IProtocol and IToplevelProtocol which just
introduces the AddRef and Release virtual methods. It's used to allow generic
code to hold a strong reference to an actor which is structurally known to be
reference counted, and generally will have limited use elsewhere.

Differential Revision: https://phabricator.services.mozilla.com/D198623
2024-01-19 20:23:22 +00:00
Nika Layzell
bd593b4dfa Bug 1867360 - Require toplevel protocols to specify which processes they expect to be bound in, r=decoder,ipc-reviewers,necko-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,aosmond,rkraesig,mccr8,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D195485
2024-01-18 23:07:18 +00:00
Natalia Csoregi
199a9020c7 Backed out changeset 9c4ce17422de (bug 1867360) for causing crashes on PRemoteQuotaObjectChild. CLOSED TREE 2024-01-08 23:18:19 +02:00
Nika Layzell
5d33ff1a48 Bug 1867360 - Require toplevel protocols to specify which processes they expect to be bound in, r=decoder,ipc-reviewers,necko-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,aosmond,rkraesig,mccr8,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D195485
2024-01-08 19:48:23 +00:00
Butkovits Atila
841c471153 Backed out changeset 30210e0efac1 (bug 1867360) for causing failures at PIPDLUnitTestChild.cpp. CLOSED TREE 2023-12-19 02:28:52 +02:00
Nika Layzell
aedf0adb86 Bug 1867360 - Require toplevel protocols to specify which processes they expect to be bound in, r=decoder,ipc-reviewers,necko-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,aosmond,rkraesig,mccr8,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D195485
2023-12-18 23:24:26 +00:00
Eden Chuang
5ca02c8ea0 Bug 1836700 - Remove BusyCount of WorkerPrivate. r=asuth,ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D182718
2023-11-13 04:00:40 +00:00
Jim Blandy
267fcde61c Bug 1850865: Improve MOZ_IPC_MESSAGE_LOG. r=ipc-reviewers,nika
Use MOZ_IPC_MESSAGE_LOG to filter GOODBYE_MESSAGE_TYPE messages.

Interpret MOZ_IPC_MESSAGE_LOG elements without the "Child" or "Parent"
suffix as a request to log both sides of the given protocol.

Differential Revision: https://phabricator.services.mozilla.com/D187167
2023-09-05 18:09:30 +00:00
Ray Kraesig
41148ee7ff Bug 1836349 - [3/3] Restrict IPCResult not to accept nonconstant strings r=nika,ipc-reviewers
Text passed to `IPCResult::Fail` (and, therefore, text passed to
`IPC_FAIL`) may end up in telemetry.

To avoid accidentally capturing unwanted information, restrict all such
text to compile-time constant strings, unless approved by data-review.

Differential Revision: https://phabricator.services.mozilla.com/D180152
2023-06-21 20:54:48 +00:00
Nika Layzell
2726756d3a Bug 1835647 - Switch FatalError to asynchronously report channel errors under fuzzing, r=ipc-reviewers,mccr8
This should avoid potential fuzzing-only issues which would be caused by
the actor being torn down synchronously after a FatalError or KillHard.
Instead, the state is set to error synchronously, blocking all further
message sending/receiving, and the notification is made async, similar
to how it is handled for normal channel errors.

Differential Revision: https://phabricator.services.mozilla.com/D180254
2023-06-08 23:09:19 +00:00
Nika Layzell
a558fc0fc9 Bug 1828389 - Ensure IPC channel is closed with error after KillHard, r=ipc-reviewers,mccr8
This patch changes KillHard() such that the IPC channel is immediately
shut down with an error after a KillHard() is performed. This is done by
fixing the previously-broken CLOSE_CHANNEL_WITH_ERROR support in
ShutDownProcess, and calling that method after KillHard().

This ensures that after the process has been killed, no further messages
will be delivered and processed, even if they were sent before the
process was killed.

In addition, the assertions and KillHard calls which are disabled for
fuzzing were changed to also shut down the channel, making fuzzing IPC
errors cause the connection to be terminated like it is in production
for these actors.

This change does not impact actors which ignore processing errors.

Differential Revision: https://phabricator.services.mozilla.com/D178383
2023-05-26 17:44:57 +00:00
James Teh
dcbc842252 Bug 1821963 part 5: Remove code to prevent handling of window messages while handling PDocAccessible sync IPDL calls. r=handyman
This actually hasn't ever been used in a shipping build of Firefox.
Although sync IPDL was tried with Windos a11y for a while when e10s was still disabled, it was never feasible and was replaced with COM proxying.

Differential Revision: https://phabricator.services.mozilla.com/D177965
2023-05-22 20:19:45 +00:00
Narcis Beleuzu
f95e590275 Backed out 6 changesets (bug 1821963) for build bustages. CLOSED TREE
Backed out changeset a92c62e304f0 (bug 1821963)
Backed out changeset da6cba0b0dd4 (bug 1821963)
Backed out changeset 4ed7ca0eb04a (bug 1821963)
Backed out changeset f2fba0ef15d9 (bug 1821963)
Backed out changeset 706e46fc2688 (bug 1821963)
Backed out changeset 6de2b9548dc6 (bug 1821963)
2023-05-22 14:05:20 +03:00
James Teh
37c6d0b47e Bug 1821963 part 5: Remove code to prevent handling of window messages while handling PDocAccessible sync IPDL calls. r=handyman
This actually hasn't ever been used in a shipping build of Firefox.
Although sync IPDL was tried with Windos a11y for a while when e10s was still disabled, it was never feasible and was replaced with COM proxying.

Differential Revision: https://phabricator.services.mozilla.com/D177965
2023-05-22 10:00:21 +00:00
Stanca Serban
78750fc551 Backed out 2 changesets (bug 1807049, bug 1828389) for mozilla::ThreadEventTarget::Dispatch xpcshell related crashes. CLOSED TREE
Backed out changeset bbd8b8bbf677 (bug 1828389)
Backed out changeset 03bd5f26f9af (bug 1807049)
2023-05-20 07:38:09 +03:00
Nika Layzell
f9cb0e0fcd Bug 1828389 - Ensure IPC channel is closed with error after KillHard, r=ipc-reviewers,mccr8
This patch changes KillHard() such that the IPC channel is immediately
shut down with an error after a KillHard() is performed. This is done by
fixing the previously-broken CLOSE_CHANNEL_WITH_ERROR support in
ShutDownProcess, and calling that method after KillHard().

This ensures that after the process has been killed, no further messages
will be delivered and processed, even if they were sent before the
process was killed.

In addition, the assertions and KillHard calls which are disabled for
fuzzing were changed to also shut down the channel, making fuzzing IPC
errors cause the connection to be terminated like it is in production
for these actors.

This change does not impact actors which ignore processing errors.

Differential Revision: https://phabricator.services.mozilla.com/D178383
2023-05-19 19:21:08 +00:00
Nika Layzell
56de9db4c4 Bug 1824465 - Part 24: Require toplevel protocols to be refcounted, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D173739
2023-04-19 22:10:11 +00:00
Noemi Erli
ebdaf2bae0 Backed out 24 changesets (bug 1824465) for causing failures in nsISupportsImpl.cpp CLOSED TREE
Backed out changeset a5c8f22b7170 (bug 1824465)
Backed out changeset b551b655ac72 (bug 1824465)
Backed out changeset 0e6768a6419c (bug 1824465)
Backed out changeset fb115ebb7fe0 (bug 1824465)
Backed out changeset aaa7a2c8aa3b (bug 1824465)
Backed out changeset 7ef94bfa90b3 (bug 1824465)
Backed out changeset a4238fd6b86f (bug 1824465)
Backed out changeset 3a88e4cfbe45 (bug 1824465)
Backed out changeset 40c2467d3162 (bug 1824465)
Backed out changeset 8f900395c72c (bug 1824465)
Backed out changeset 92e4c6e4d73c (bug 1824465)
Backed out changeset 445c5d5d9661 (bug 1824465)
Backed out changeset de51ed5389d9 (bug 1824465)
Backed out changeset 72049d72bcb6 (bug 1824465)
Backed out changeset 126773c2427a (bug 1824465)
Backed out changeset 886e76bc80be (bug 1824465)
Backed out changeset a69a851411f0 (bug 1824465)
Backed out changeset 703599cf6189 (bug 1824465)
Backed out changeset 11ecb78ebc15 (bug 1824465)
Backed out changeset 563255aaa1e1 (bug 1824465)
Backed out changeset d1bf32c2a6c6 (bug 1824465)
Backed out changeset ef28b2777487 (bug 1824465)
Backed out changeset a2015d354bb1 (bug 1824465)
Backed out changeset 31d6b53fdc6a (bug 1824465)
2023-04-06 01:50:55 +03:00
Nika Layzell
bda532a9af Bug 1824465 - Part 24: Require toplevel protocols to be refcounted, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D173739
2023-04-05 21:33:45 +00:00
Christian Holler (:decoder)
46e64be8b3 Bug 1821010 - Remove legacy IPC fuzzing code. r=truber,nika
Differential Revision: https://phabricator.services.mozilla.com/D171981
2023-03-23 14:53:22 +00:00
Nika Layzell
cdd61f472e Bug 1789440 - Track reply message IDs for MessageChannel async replies, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D156569
2022-09-07 23:38:45 +00:00
Noemi Erli
d9ad447154 Backed out changeset 0f2c5cc743c8 (bug 1789440) for causing mass failures 2022-09-08 01:54:54 +03:00
Nika Layzell
b3d3f55211 Bug 1789440 - Track reply message IDs for MessageChannel async replies, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D156569
2022-09-07 20:30:39 +00:00
Nika Layzell
afe4f1d855 Bug 1779792 - Part 5: Add a unique nsID field to each MessageChannel pair, r=ipc-reviewers,mccr8
This won't be used for any security or routing purposes, but can be useful for
debugging. It will be used in the future by the profiler to correlate sent and
received message events across processes.

Differential Revision: https://phabricator.services.mozilla.com/D153621
2022-08-10 14:55:23 +00:00
Nika Layzell
e7200aa7a5 Bug 1779792 - Part 2: Use an Endpoint to bind the initial actor in child processes, r=ipc-reviewers,necko-reviewers,media-playback-reviewers,mccr8,alwu
This type is also used in other places to start non-initial actors, and will
allow us to attach additional state more easily without needing to thread it
through every child process callsite manually.

Differential Revision: https://phabricator.services.mozilla.com/D153618
2022-08-10 14:55:22 +00:00
Jim Blandy
769dc2dbf0 Bug 1777656: Delete mozilla::ipc::SharedMemory::SharedMemorytype. r=nika,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D150852
2022-07-05 20:08:31 +00:00
Nika Layzell
1a428600f7 Bug 1771234 - Make it easier to use a specific serial event target when binding an actor, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D147381
2022-06-01 14:35:16 +00:00
Nika Layzell
42dba697a5 Bug 1768476 - Part 1: Consistently pass IPC::Message around by UniquePtr, r=ipc-reviewers,mccr8
This makes passing around the type more consistent, and hopefully will make
changes to IPC::Message easier to work with in the future.

In addition, this should save us a few copies as we move the message type into
and out of UniquePtr, however I expect this won't make much of a difference.

Differential Revision: https://phabricator.services.mozilla.com/D145885
2022-05-10 21:37:25 +00:00
Noemi Erli
13882c1928 Backed out 2 changesets (bug 1768476) for causing build bustages in ProtocolFuzzer.h
Backed out changeset c9cb03579c09 (bug 1768476)
Backed out changeset 6732ef394d0e (bug 1768476)
2022-05-10 23:39:29 +03:00
Nika Layzell
61ad4be21c Bug 1768476 - Part 1: Consistently pass IPC::Message around by UniquePtr, r=ipc-reviewers,mccr8
This makes passing around the type more consistent, and hopefully will make
changes to IPC::Message easier to work with in the future.

In addition, this should save us a few copies as we move the message type into
and out of UniquePtr, however I expect this won't make much of a difference.

Differential Revision: https://phabricator.services.mozilla.com/D145885
2022-05-10 17:45:42 +00:00