Commit Graph

1588 Commits

Author SHA1 Message Date
Nika Layzell
734a0debe0 Bug 1956103 - Part 2: Replace ChannelCapability with EventTargetAndLockCapability, r=ipc-reviewers,mccr8
This is the generalized version of the `ChannelCapability` type, which has now
been moved into XPCOM so it can be used by other types. The functionality and
checking should be identical.

Differential Revision: https://phabricator.services.mozilla.com/D242845
2025-04-11 19:42:01 +00:00
Yannis Juglaret
8de17578df Bug 1956398 - Avoid duplicating pseudo-handles in ipc_channel_win.cc. r=nika a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D243135
2025-03-26 18:35:09 +00:00
serge-sans-paille
ba8d05e7a1 Bug 1953340 - Fix bad interaction between memset and packed structure on arm r=nika,ipc-reviewers
Bug has been submitted and approved upstream, see https://github.com/chromium/chromium/pull/280

Differential Revision: https://phabricator.services.mozilla.com/D241777
2025-03-17 15:49:41 +00:00
Alex Franchuk
da658fa4b2 Bug 1942129 pt4 - Convert old shmem call sites to use the new shmem classes r=ipc-reviewers,media-playback-reviewers,padenot,lsalzman,aosmond,nika
While much of this is simply converting code (and removing extraneous
`size` parameters), toolkit/xre/GeckoArgs.{h,cpp} has some significant
changes to support sending read-only handles (which is all we need!).

Differential Revision: https://phabricator.services.mozilla.com/D236750
2025-03-04 22:11:12 +00:00
Butkovits Atila
2406ce261c Backed out 8 changesets (bug 1942129) for causing bustages at SharedMemoryMapping.h. CLOSED TREE
Backed out changeset 8d9053f1c203 (bug 1942129)
Backed out changeset 393e3c507c27 (bug 1942129)
Backed out changeset 8240d353d224 (bug 1942129)
Backed out changeset 8c4cd026b720 (bug 1942129)
Backed out changeset 742634b0d6e9 (bug 1942129)
Backed out changeset d16857f9812f (bug 1942129)
Backed out changeset 7ff7af041ee7 (bug 1942129)
Backed out changeset ef41d9e4c7de (bug 1942129)
2025-03-04 00:43:23 +02:00
Alex Franchuk
f7ee08eef3 Bug 1942129 pt4 - Convert old shmem call sites to use the new shmem classes r=ipc-reviewers,media-playback-reviewers,padenot,lsalzman,aosmond,nika
While much of this is simply converting code (and removing extraneous
`size` parameters), toolkit/xre/GeckoArgs.{h,cpp} has some significant
changes to support sending read-only handles (which is all we need!).

Differential Revision: https://phabricator.services.mozilla.com/D236750
2025-03-03 19:53:20 +00:00
Jed Davis
be8578ac33 Bug 1944669 - Suppress ProcessWatcher logspam introduced in earlier rewrite. r=ipc-reviewers,mccr8
The case in question is where the process exits before the timeout
expires and it's a forkserver child.  Previously (before bug 1658072)
there wouldn't be a log message in this case, but otherwise the effect
was the same: if a process with the given pid was still running, it
would be sent `SIGKILL`.

Differential Revision: https://phabricator.services.mozilla.com/D237857
2025-02-14 01:33:08 +00:00
Nika Layzell
1cecdf41cf Bug 1927209 - Try to handle fragmented memory better for large buffers in IPC, r=afranchuk,ipc-reviewers,jld
This adds a new type, `SharedMemoryCursor`, as well as platform support
for mapping subregions of shared memory handles. This type will attempt
to map the entire shared memory region, and will back off on the size of
the region until it can successfully map a portion of the region to read
data from.

Ideally, this should help reduce the chances of encountering memory
fragmentation issues when sending large JS structured clone buffers over
IPC.

Differential Revision: https://phabricator.services.mozilla.com/D233116
2025-02-13 21:29:21 +00:00
Alexandru Marc
514fa30328 Backed out 2 changesets (bug 1927209, bug 1947418) for causing out of memory issues a=backout
Backed out changeset 280cd0c72bdd (bug 1947418)
Backed out changeset 577fcfb38a89 (bug 1927209)
2025-02-12 13:00:53 +02:00
Nika Layzell
a5bc212f36 Bug 1927209 - Try to handle fragmented memory better for large buffers in IPC, r=afranchuk,ipc-reviewers,jld
This adds a new type, `SharedMemoryCursor`, as well as platform support
for mapping subregions of shared memory handles. This type will attempt
to map the entire shared memory region, and will back off on the size of
the region until it can successfully map a portion of the region to read
data from.

Ideally, this should help reduce the chances of encountering memory
fragmentation issues when sending large JS structured clone buffers over
IPC.

Differential Revision: https://phabricator.services.mozilla.com/D233116
2025-02-10 19:30:09 +00:00
Jake Senne
f791d53be6 Bug 1288016 - Replaced MOZ_ALIGNOF() with alignof(). r=media-playback-reviewers,xpcom-reviewers,emilio,glandium,karlt
Replaced all instances of `MOZ_ALIGNOF` with `alignof` and removed said function. Removed `MOZ_ALIGNAS_IN_STRUCT` (unused since bug 1572205).

Differential Revision: https://phabricator.services.mozilla.com/D230730
2025-01-31 14:43:10 +00:00
Jan Varga
60e8ea3420 Bug 1943951 - Rename kShmemThreshold to kMessageBufferShmemThreshold and move it to header with documentation; r=nika
Differential Revision: https://phabricator.services.mozilla.com/D235816
2025-01-29 08:33:05 +00:00
Jed Davis
ae21f9674e Bug 1941910 - Use dummy ProcessWatcher on Android and iOS. r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D234433
2025-01-17 03:16:27 +00:00
Cosmin Sabou
05bc4c0400 No bug - correct some typos in manifest files. a=typo-fix
CLOSED TREE
2025-01-10 23:43:19 +02:00
Jed Davis
c5c5ce334f Bug 1940035 - Make more of IsZombieProcess's log messages debug-only. r=ipc-reviewers,mccr8
If a process is exiting, currently the fork server will collect it
asynchronously from the parent process, so the `kill(handle, 0)` call
will succeed but attempts to read its status via procfs can fail (either
`open`ing or `read`ing the `stat` file).  Because this can happen in
normal operation, we shouldn't log about it on release builds, but debug
builds will still log just in case it fails for an unexpected reason.

Differential Revision: https://phabricator.services.mozilla.com/D233315
2025-01-07 17:54:34 +00:00
Jed Davis
13609c741b Bug 1940035 - Fix log message in IsZombieProcess. r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D233314
2025-01-07 17:54:34 +00:00
Jed Davis
a8862d5aee Bug 1658072 - Cleanup: assert that libevent's signal handling code is never used. r=nika
Given that libevent's signal handling code is known to have race
conditions, and there are fundamental issues that make it hard to fix
upstream, and previous patches have removed our last usage of it, we
should assert that it's no longer used.

Differential Revision: https://phabricator.services.mozilla.com/D141312
2025-01-06 19:34:11 +00:00
Jed Davis
5181cd641d Bug 1658072 - Cleanup: remove the signal handling glue in the IPC event loop. r=nika
Now that we're no longer using libevent's signal handling, we don't need
an OO wrapper for it.

Differential Revision: https://phabricator.services.mozilla.com/D141311
2025-01-06 19:34:11 +00:00
Jed Davis
e8c0afd5c7 Bug 1658072 - Rewrite the Unix implementation of IPC process termination handling. r=nika
This patch rewrites the Unix backend of ProcessWatcher for two reasons:

1. To remove the use of libevent's signal handling, which has concurrency
   bugs that can't be easily fixed upstream (see Bugzilla for details)

2. To simplify the code in general; in particular, the new version has one
   place where the process and its exit status are consumed from the OS

The new implementation uses the same pipe-to-self technique as libevent
(and which we use elsewhere) to deal with async signal safety.  Unlike
the previous version, there is a single object which manages all
monitored child processes rather than one each.  (Previously, this
multiplexing was done inside libevent.)

Differential Revision: https://phabricator.services.mozilla.com/D141309
2025-01-06 19:34:10 +00:00
Jed Davis
5edb0f9e17 Bug 1658072 - Preamble: refactor IsProcessDead. r=ipc-reviewers,nika
This patch rearranges the abstraction around `waitpid`/`waitid`.  There
is now a function `WaitForProcess` that returns more detailed information
about the process status, and then a wrapper `IsProcessDead` which is
private to the `ProcessWatcher` which simplifies the results and logs
information to stderr.  In the future, the extended information could be
exposed to observers within Gecko in some way.

Differential Revision: https://phabricator.services.mozilla.com/D230468
2025-01-06 19:34:10 +00:00
Goloman Adrian
a8c1ca989a Backed out 5 changesets (bug 1658072) for causing build bustages @process_watcher_posix_sigchld.cc. CLOSED TREE
Backed out changeset 906d7fc507a3 (bug 1658072)
Backed out changeset bab46fe43af6 (bug 1658072)
Backed out changeset 1618e1a59f87 (bug 1658072)
Backed out changeset 35b64d418961 (bug 1658072)
Backed out changeset a43887934808 (bug 1658072)
2024-12-19 10:42:20 +02:00
Otto Länd
5f7fc1b17d Bug 1658072: apply code formatting via Lando
# ignore-this-changeset
2024-12-19 06:21:31 +00:00
Jed Davis
6b5219a565 Bug 1658072 - Cleanup: assert that libevent's signal handling code is never used. r=nika
Given that libevent's signal handling code is known to have race
conditions, and there are fundamental issues that make it hard to fix
upstream, and previous patches have removed our last usage of it, we
should assert that it's no longer used.

Differential Revision: https://phabricator.services.mozilla.com/D141312
2024-12-19 06:18:27 +00:00
Jed Davis
eac5c5c9ab Bug 1658072 - Cleanup: remove the signal handling glue in the IPC event loop. r=nika
Now that we're no longer using libevent's signal handling, we don't need
an OO wrapper for it.

Differential Revision: https://phabricator.services.mozilla.com/D141311
2024-12-19 06:18:26 +00:00
Jed Davis
47a69aa686 Bug 1658072 - Rewrite the Unix implementation of IPC process termination handling. r=nika
This patch rewrites the Unix backend of ProcessWatcher for two reasons:

1. To remove the use of libevent's signal handling, which has concurrency
   bugs that can't be easily fixed upstream (see Bugzilla for details)

2. To simplify the code in general; in particular, the new version has one
   place where the process and its exit status are consumed from the OS

The new implementation uses the same pipe-to-self technique as libevent
(and which we use elsewhere) to deal with async signal safety.  Unlike
the previous version, there is a single object which manages all
monitored child processes rather than one each.  (Previously, this
multiplexing was done inside libevent.)

Differential Revision: https://phabricator.services.mozilla.com/D141309
2024-12-19 06:18:26 +00:00
Jed Davis
3f5fc49b0e Bug 1658072 - Preamble: refactor IsProcessDead. r=ipc-reviewers,nika
This patch rearranges the abstraction around `waitpid`/`waitid`.  There
is now a function `WaitForProcess` that returns more detailed information
about the process status, and then a wrapper `IsProcessDead` which is
private to the `ProcessWatcher` which simplifies the results and logs
information to stderr.  In the future, the extended information could be
exposed to observers within Gecko in some way.

Differential Revision: https://phabricator.services.mozilla.com/D230468
2024-12-19 06:18:26 +00:00
Jed Davis
3203963ce9 Bug 1937265 - Fix some bugs in setproctitle introduced in bug 1915152. r=gerard-majax
I noticed and fixed a couple of bugs in our Linux setproctitle,
introduced by an earlier patch to copy part of the environment back into
the initial env space to make it readable from `/proc/{pid}/environ`:

1. The env vars were being written to the wrong point in the buffer and
   would overwrite the end of the cmdline string (if it was longer than
   the original args, which it generally is in our use case).

2. The comparison with the elements of `kEnvSkip` was passing the wrong
   value to strncmp, so we might not skip the env vars we intended to.

Differential Revision: https://phabricator.services.mozilla.com/D232146
2024-12-17 19:37:14 +00:00
Andrew McCreight
b3623f30a2 Bug 1931877, part 2 - Replace 2 arg MOZ_DIAGNOSTIC_ASSERT(false) with MOZ_DIAGNOSTIC_CRASH. r=necko-reviewers,win-reviewers,glandium,rkraesig,valentin
Differential Revision: https://phabricator.services.mozilla.com/D229361
2024-11-20 16:37:50 +00:00
Nika Layzell
7d9829fbec Bug 1928734 - Part 2: Centralize handling of the IPC IO thread, r=ipc-reviewers,media-playback-reviewers,karlt,jld,handyman
Previously the handling for the IO thread was split between
BrowserProcessSubThread (a replication of the background thread infrastructure
used by Chromium during the IPC import, which is only used for the IO thread in
Gecko), and IOThreadChild (a wrapper around ChildThread, which was imported
from Chromium's source).

This meant that there was little code-sharing between the parent and child
processes, and that the lifecycle of the IO thread was perhaps less clear.

This refactors the code to centralize handling of these threads, and provide a
basic common interface. At the moment, actually hooking up async IO listeners
is still done using the Chromium interfaces.

Differential Revision: https://phabricator.services.mozilla.com/D227739
2024-11-19 18:34:02 +00:00
Butkovits Atila
8d194ab684 Backed out 3 changesets (bug 1928734) for causing linting failure. CLOSED TREE
Backed out changeset 1b9e50c4c129 (bug 1928734)
Backed out changeset dd5cabd3fbc4 (bug 1928734)
Backed out changeset a9f66c1d560d (bug 1928734)
2024-11-19 01:49:22 +02:00
Nika Layzell
299a27a846 Bug 1928734 - Part 2: Centralize handling of the IPC IO thread, r=ipc-reviewers,media-playback-reviewers,karlt,jld
Previously the handling for the IO thread was split between
BrowserProcessSubThread (a replication of the background thread infrastructure
used by Chromium during the IPC import, which is only used for the IO thread in
Gecko), and IOThreadChild (a wrapper around ChildThread, which was imported
from Chromium's source).

This meant that there was little code-sharing between the parent and child
processes, and that the lifecycle of the IO thread was perhaps less clear.

This refactors the code to centralize handling of these threads, and provide a
basic common interface. At the moment, actually hooking up async IO listeners
is still done using the Chromium interfaces.

Differential Revision: https://phabricator.services.mozilla.com/D227739
2024-11-18 22:54:54 +00:00
serge-sans-paille
5946338a6a Bug 1920718 - Annotate all global variable with runtime initialization attributes r=glandium,application-update-reviewers,media-playback-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,gfx-reviewers,aosmond,lina,nalexander,aabh,geckoview-reviewers,win-reviewers,gstoll,m_kato
MOZ_RUNINIT => initialized at runtime
MOZ_CONSTINIT => initialized at compile time
MOZ_GLOBINIT => initialized either at runtime or compile time, depending on template parameter, macro parameter etc
This annotation is only understood by our clang-tidy plugin. It has no
effect on regular compilation.

Differential Revision: https://phabricator.services.mozilla.com/D223341
2024-10-30 11:05:24 +00:00
Jed Davis
0f5c33cd13 Bug 1901996 - Make IPC memfds non-executable if supported. r=ipc-reviewers,nika
This patch also uses `MFD_ALLOW_SEALING` unconditionally, even if we're
not planning to seal the memfd, because `MFD_NOEXEC_SEAL` implies it.
(We could re-add `F_SEAL_SEAL` explicitly in that case but I don't think
it makes a meaningful difference in our use cases.)

Differential Revision: https://phabricator.services.mozilla.com/D222575
2024-10-29 02:45:35 +00:00
Jed Davis
775b17cdc5 Bug 1926763 - Make the zombie process warning message debug-only. r=ipc-reviewers,mccr8
The situation that the zombie check from bug 1881386 was added for is
applicable to our CI but not to normal use.  We do sometimes detect
zombie processes in normal operation, but this isn't inherently a
problem.  Therefore, the log message for this is made debug-only to avoid
confusion for users of release builds.

Also, a comment added in bug 1881386 was missing the bug number; this has
been fixed.

Differential Revision: https://phabricator.services.mozilla.com/D226863
2024-10-29 02:24:07 +00:00
Alex Franchuk
6e5676f12a Bug 1454816 - Remove base::SharedMemory r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D224154
2024-10-21 18:43:25 +00:00
Sandor Molnar
abe7f841ca Backed out 4 changesets (bug 1454816) for causing build bustages. CLOSED TREE
Backed out changeset 3e8d2c47138c (bug 1454816)
Backed out changeset 80ff20241831 (bug 1454816)
Backed out changeset 28c2d6d2a683 (bug 1454816)
Backed out changeset 236943ab4142 (bug 1454816)
2024-10-21 20:15:13 +03:00
Alex Franchuk
53f7eab05e Bug 1454816 - Remove base::SharedMemory r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D224154
2024-10-21 13:08:44 +00:00
Alexandre Lissy
e45dae23ec Bug 1915152 - Copying back some of environ into kernel-exposed memory space r=jld
Differential Revision: https://phabricator.services.mozilla.com/D221021
2024-10-21 06:05:42 +00:00
Butkovits Atila
0f3a88d758 Backed out 8 changesets (bug 1918596, bug 1917575, bug 1874689, bug 1925181, bug 1917844, bug 1925274, bug 1915152) for causing failures at Sandbox.cpp. CLOSED TREE
Backed out changeset ce2138248319 (bug 1874689)
Backed out changeset fbe9fbb6ae72 (bug 1925181)
Backed out changeset c9896c8962cb (bug 1925274)
Backed out changeset 6eddbad5949c (bug 1918596)
Backed out changeset b9bf86fa1c74 (bug 1917844)
Backed out changeset 1d4cd83d1a39 (bug 1917844)
Backed out changeset 264a5140fbcb (bug 1917575)
Backed out changeset 87b8512c67c9 (bug 1915152)
2024-10-19 23:27:56 +03:00
Alexandre Lissy
b83bc71694 Bug 1915152 - Copying back some of environ into kernel-exposed memory space r=jld
Differential Revision: https://phabricator.services.mozilla.com/D221021
2024-10-19 08:55:30 +00:00
Cristina Horotan
9b33881471 Backed out 4 changesets (bug 1454816) for causing build bustages at nsIStringBundle.h CLOSED TREE
Backed out changeset bed340babebd (bug 1454816)
Backed out changeset f7499fb49eb0 (bug 1454816)
Backed out changeset 9a82c5828c53 (bug 1454816)
Backed out changeset efe7bc48a16d (bug 1454816)
2024-10-18 23:41:27 +03:00
Alex Franchuk
dc8e8248c7 Bug 1454816 - Remove base::SharedMemory r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D224154
2024-10-18 16:58:46 +00:00
Adi
b9802f791a Backed out 6 changesets (bug 1918596, bug 1915152, bug 1917844, bug 1917575, bug 1874689) for causing valgrind bustages. CLOSED TREE
Backed out changeset b7f977ce6ea0 (bug 1874689)
Backed out changeset e9ccbb43f903 (bug 1918596)
Backed out changeset 39bf07957c07 (bug 1917844)
Backed out changeset 61d1c38cc516 (bug 1917844)
Backed out changeset 2a9a2bca99ce (bug 1917575)
Backed out changeset dab1b77688b2 (bug 1915152)
2024-10-17 14:56:41 +03:00
Alexandre Lissy
06241b0210 Bug 1915152 - Copying back some of environ into kernel-exposed memory space r=jld
Differential Revision: https://phabricator.services.mozilla.com/D221021
2024-10-17 06:29:53 +00:00
Nika Layzell
eae67d29ac Bug 1917904 - Support passing mach ports into new processes, r=ipc-reviewers,jld
This builds on the support from bug 1440207 to allow passing mach ports into
new content processes. This is done using the existing initial mach IPC already
used to transfer a mach task port to the parent process on child process
creation.

Differential Revision: https://phabricator.services.mozilla.com/D221708
2024-10-16 22:51:10 +00:00
Cosmin Sabou
d1b22b68ad Backed out 6 changesets (bug 1917575, bug 1917844, bug 1874689, bug 1918596, bug 1915152) for causing ContentChild crashes. CLOSED TREE
Backed out changeset d6dc6d8085b5 (bug 1874689)
Backed out changeset 8c3916995be2 (bug 1918596)
Backed out changeset f77e369d1e0f (bug 1917844)
Backed out changeset 3bee9479316a (bug 1917844)
Backed out changeset 5c72e4a84a2c (bug 1917575)
Backed out changeset af3350e58b0a (bug 1915152)
2024-10-17 00:51:07 +03:00
Alexandre Lissy
611442ac08 Bug 1915152 - Copying back some of environ into kernel-exposed memory space r=jld
Differential Revision: https://phabricator.services.mozilla.com/D221021
2024-10-16 20:10:54 +00:00
Tamas Szentpeteri
8285dfaab8 Backed out changeset 4b1409597101 (bug 1920718) for causing bp bustages on rapl.cpp. 2024-10-08 23:27:18 +03:00
serge-sans-paille
1966f9a43c Bug 1920718 - Annotate all global variable with runtime initialization as MOZ_RUNINIT r=application-update-reviewers,media-playback-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,gfx-reviewers,aosmond,lina,nalexander,aabh
This annotation is only understood by our clang-tidy plugin. It has no
effect on regular compilation.

Differential Revision: https://phabricator.services.mozilla.com/D223341
2024-10-08 16:49:51 +00:00
Emilio Cobos Álvarez
bd6dfe4ca0 Bug 1922571 - Remove one win-specific include I missed.
MANUAL PUSH: Bustage fix CLOSED TREE
2024-10-04 10:58:17 +02:00