2978 Commits

Author SHA1 Message Date
Yannis Juglaret
072d3d69de Bug 1839299 - Use a finer-grained strategy to protect RtlLookupFunctionEntry against deadlocks. r=win-reviewers,rkraesig
On 64-bit Windows (x86_64, aarch64), stack walking relies on
RtlLookupFunctionEntry to navigate from one frame to the next. This
function acquires up to two ntdll internal locks when it is called.

The profiler and the background hang monitor both need to walk the
stacks of suspended threads. This can lead to deadlock situations,
which so far we have avoided with stack walk suppressions. We guard some
critical paths to mark them as suppressing stack walk, and we forbid
stack walking when any thread is currently on such path.

While stack walk suppression has helped remove most deadlock situations,
some can remain because it is hard to detect and manually annotate all
the paths that could lead to a deadlock situation. Another drawback is
that stack walk suppression disables stack walking for much larger
portions of code than required. For example, we disable stack walking
for LdrLoadDll, so we cannot collect stacks while we are loading a DLL.
Yet, the lock that could lead to a deadlock situation is only held
during a very small portion of the whole time spent in LdrLoadDll.

This patch addresses these two issues by implementing a finer-grained
strategy to avoid deadlock situations. We acquire the pointers to the
internel ntdll locks through a single-stepped execution of
RtlLookupFunctionEntry. This allows us to try to acquire the locks
non-blockingly so that we can guarantee safe stack walking with no
deadlock.

If we fail to collect pointers to the locks, we fall back to using stack
walk suppressions like before. This way we get the best of both worlds:
if we are confident that the situation is under control, we will use the
new strategy and get better profiler accuracy and no deadlock; in case
of doubt, we can still use the profiler thanks to stack walk
suppressions.

Differential Revision: https://phabricator.services.mozilla.com/D223498
2024-10-17 13:47:04 +00:00
Adi
43e200afe1 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
Adi
70758f017d Backed out changeset e6475b7e0602 (bug 1839299) for causing instrumented build bustages. 2024-10-17 14:55:27 +03:00
Yannis Juglaret
ebdc900582 Bug 1839299 - Use a finer-grained strategy to protect RtlLookupFunctionEntry against deadlocks. r=win-reviewers,rkraesig
On 64-bit Windows (x86_64, aarch64), stack walking relies on
RtlLookupFunctionEntry to navigate from one frame to the next. This
function acquires up to two ntdll internal locks when it is called.

The profiler and the background hang monitor both need to walk the
stacks of suspended threads. This can lead to deadlock situations,
which so far we have avoided with stack walk suppressions. We guard some
critical paths to mark them as suppressing stack walk, and we forbid
stack walking when any thread is currently on such path.

While stack walk suppression has helped remove most deadlock situations,
some can remain because it is hard to detect and manually annotate all
the paths that could lead to a deadlock situation. Another drawback is
that stack walk suppression disables stack walking for much larger
portions of code than required. For example, we disable stack walking
for LdrLoadDll, so we cannot collect stacks while we are loading a DLL.
Yet, the lock that could lead to a deadlock situation is only held
during a very small portion of the whole time spent in LdrLoadDll.

This patch addresses these two issues by implementing a finer-grained
strategy to avoid deadlock situations. We acquire the pointers to the
internel ntdll locks through a single-stepped execution of
RtlLookupFunctionEntry. This allows us to try to acquire the locks
non-blockingly so that we can guarantee safe stack walking with no
deadlock.

If we fail to collect pointers to the locks, we fall back to using stack
walk suppressions like before. This way we get the best of both worlds:
if we are confident that the situation is under control, we will use the
new strategy and get better profiler accuracy and no deadlock; in case
of doubt, we can still use the profiler thanks to stack walk
suppressions.

Differential Revision: https://phabricator.services.mozilla.com/D223498
2024-10-17 09:43:15 +00:00
Alexandre Lissy
d37fc481d9 Bug 1917575 - Interpose __register_atfork()/pthread_atfork() and run it after clone() r=jld
Differential Revision: https://phabricator.services.mozilla.com/D221387
2024-10-17 06:29:53 +00:00
Cosmin Sabou
1bc4690f6a 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
5a24bd7766 Bug 1917575 - Interpose __register_atfork()/pthread_atfork() and run it after clone() r=jld
Differential Revision: https://phabricator.services.mozilla.com/D221387
2024-10-16 20:10:54 +00:00
Emilio Cobos Álvarez
ed43bbbbb0 Bug 1922250 - Align skeleton ui with nsWindow more closely. r=win-reviewers,rkraesig
This maps better to the code we have in nsWindow, and fixes a couple
bugs which caused maximized skeleton UI-consuming windows to be
mispositioned with the following patches.

Differential Revision: https://phabricator.services.mozilla.com/D225100
2024-10-14 10:55:25 +00:00
Noemi Erli
ffa33e3898 Backed out 3 changesets (bug 1922250) for causing failures in browser_1446343-windowsize.js CLOSED TREE
Backed out changeset f4e18a092cba (bug 1922250)
Backed out changeset 9af0852c057c (bug 1922250)
Backed out changeset c7ebee651e07 (bug 1922250)
2024-10-12 07:48:39 +03:00
Emilio Cobos Álvarez
ffb08d883e Bug 1922250 - Align skeleton ui with nsWindow more closely. r=win-reviewers,rkraesig
This maps better to the code we have in nsWindow, and fixes a couple
bugs which caused maximized skeleton UI-consuming windows to be
mispositioned with the following patches.

Differential Revision: https://phabricator.services.mozilla.com/D225100
2024-10-11 08:37:23 +00:00
Tamas Szentpeteri
8be45dd280 Backed out changeset 4b1409597101 (bug 1920718) for causing bp bustages on rapl.cpp. 2024-10-08 23:27:18 +03:00
serge-sans-paille
069a97307f 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
Paul Adenot
da6e72dc6c Bug 1921288 - Add a way to get the associated duration type from TimeStamp and AwakeTimeStamp. r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D223792
2024-10-03 08:54:11 +00:00
Paul Adenot
78ab790d8f Bug 1921288 - Add some arithmetic and conversion functions to AwakeTimeStamp. r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D223791
2024-10-03 08:54:11 +00:00
Paul Adenot
3c42e9a3bc Bug 1921288 - Teach AwakeTimeStamp to do precise timestamps on Windows, rename methods. r=gsvelto
This uses a function that has been introduced in Windows 10.

Differential Revision: https://phabricator.services.mozilla.com/D223790
2024-10-03 08:54:11 +00:00
Sandor Molnar
2557cd3d7d Backed out 6 changesets (bug 1921288) for causing build bustages. CLOSED TREE
Backed out changeset c03d69e623b9 (bug 1921288)
Backed out changeset 111bef5016a9 (bug 1921288)
Backed out changeset 17130f51de88 (bug 1921288)
Backed out changeset a4acd335a710 (bug 1921288)
Backed out changeset c5fc8bc8273a (bug 1921288)
Backed out changeset 744f7a82c471 (bug 1921288)
2024-10-02 21:11:06 +03:00
Paul Adenot
3043e0394d Bug 1921288 - Fix bustage, QueryUnbiasedInterruptTimePrecise return value is void
Differential Revision: https://phabricator.services.mozilla.com/D224359
2024-10-02 16:45:10 +00:00
Paul Adenot
e3c35ceb52 Bug 1921288 - Add a way to get the associated duration type from TimeStamp and AwakeTimeStamp. r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D223792
2024-10-02 16:01:04 +00:00
Paul Adenot
badc695bfb Bug 1921288 - Add some arithmetic and conversion functions to AwakeTimeStamp. r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D223791
2024-10-02 16:01:03 +00:00
Paul Adenot
72a3c75971 Bug 1921288 - Teach AwakeTimeStamp to do precise timestamps on Windows, rename methods. r=gsvelto
This uses a function that has been introduced in Windows 10.

Differential Revision: https://phabricator.services.mozilla.com/D223790
2024-10-02 16:01:03 +00:00
Nika Layzell
e40dad70cf Bug 1440207 - Part 3h: Android support for file geckoargs, r=geckoview-reviewers,ipc-reviewers,owlish,jld
This changes how file descriptors are passed to Android child processes to
support the new ChildProcessArgs model. Instead of explicit lists of FDs to pass
around, a single array of FDs is passed from the parent process into the child
service and then passed into GeckoArgs.

Differential Revision: https://phabricator.services.mozilla.com/D221378
2024-10-01 22:21:50 +00:00
Cristian Tuns
44fb28a14e Backed out 13 changesets (bug 1440207) for causing multiple failures. CLOSED TREE
Backed out changeset c9f33dfc1cc5 (bug 1440207)
Backed out changeset 76d823a34925 (bug 1440207)
Backed out changeset 75a99142ee1c (bug 1440207)
Backed out changeset b4d283d3e8da (bug 1440207)
Backed out changeset ea81a08ce181 (bug 1440207)
Backed out changeset c581a4e8cd15 (bug 1440207)
Backed out changeset d13799a1dc26 (bug 1440207)
Backed out changeset 6d715586c911 (bug 1440207)
Backed out changeset 30ff6a4db1d0 (bug 1440207)
Backed out changeset 2da0bbfdfee5 (bug 1440207)
Backed out changeset f3445c3fdd5e (bug 1440207)
Backed out changeset 07fbed499fe4 (bug 1440207)
Backed out changeset 1c2ac609c466 (bug 1440207)
2024-09-24 19:10:35 -04:00
Nika Layzell
3862954606 Bug 1440207 - Part 3h: Android support for file geckoargs, r=geckoview-reviewers,ipc-reviewers,owlish,jld
This changes how file descriptors are passed to Android child processes to
support the new ChildProcessArgs model. Instead of explicit lists of FDs to pass
around, a single array of FDs is passed from the parent process into the child
service and then passed into GeckoArgs.

Differential Revision: https://phabricator.services.mozilla.com/D221378
2024-09-24 19:28:12 +00:00
Mike Hommey
fc327076fb Bug 1918285 - Avoid lz4frame symbols being exported from gtest libxul. r=firefox-build-system-reviewers,sergesanspaille
The lz4 symbols were never meant to be exposed, the API in Compression.h
being the official way to use it. This is we had LZ4LIB_VISIBILITY set to
nothing. Unfortunately, that wasn't enough, because there is another
similar define for lz4frame: LZ4FLIB_VISIBILITY.

So we had been exporting those lz4frame symbols from firefox-bin
forever, without noticing, but it didn't cause problems until the
symbols were moved to libxul. With them moved to libxul, we end up
with the situation where we might actually end up using the symbols
from the system liblz4, which is pulled indirectly through other
dependencies (through libsystemd, which comes through libdbus).

This is all fine-ish on a "normal" opt build, but with LTO, things
end up such that some calls go through our copy of lz4frame and others
through the system one, and the discrepancy causes a crash.

The symbols file for non-gtest libxul, that hides all symbols but a few,
was saving the non-gtest case, fortunately.

Differential Revision: https://phabricator.services.mozilla.com/D222574
2024-09-18 05:23:16 +00:00
Noemi Erli
930a787958 Backed out 8 changesets (bug 1634785) for causing bustages in EHABIStackWalk.cpp CLOSED TREE
Backed out changeset 3ea11e90d26d (bug 1634785)
Backed out changeset cb492d775d37 (bug 1634785)
Backed out changeset 1c43270bdcaf (bug 1634785)
Backed out changeset 42d0181c117a (bug 1634785)
Backed out changeset 32b940c88cca (bug 1634785)
Backed out changeset f9b6ae065ffc (bug 1634785)
Backed out changeset 2abc88b08f69 (bug 1634785)
Backed out changeset bf73d2f240f1 (bug 1634785)
2024-09-17 02:48:59 +03:00
Nazım Can Altınova
6b1d8370ec Bug 1634785 - Rename BaseProfilerSharedLibraries.h to SharedLibraries.h r=mstange,profiler-reviewers
Now that we only have one implementation of this code, we don't have to
differentiate it with "BaseProfiler".

Differential Revision: https://phabricator.services.mozilla.com/D220888
2024-09-16 21:09:34 +00:00
Nazım Can Altınova
c90e007aa4 Bug 1634785 - Deduplicate shared libraries code r=mstange,profiler-reviewers
This patch finally removes the shared libraries code that was inside
tools/profiler and uses the one in base profiler everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D220887
2024-09-16 21:09:34 +00:00
Nazım Can Altınova
e22fc5c7bc Bug 1634785 - Return early for ntdll.dll if EAF+ is enabled on mozglue SharedLibrary as well r=mstange,profiler-reviewers,bobowen
We already had this early return on the shared-libraries code that was on the
tools/profiler directory. Adding this check here as well to keep the both files
in sync. It will help us deduplicating the shared libraries code later.

Differential Revision: https://phabricator.services.mozilla.com/D220908
2024-09-16 21:09:33 +00:00
Nazım Can Altınova
9d03b260f0 Bug 1634785 - Do not expose AddSharedLibraryFromModuleInfo that's only used internally r=mstange,profiler-reviewers
This method was used only internally, and having this method declaration causes
issues. That's this method was already like this in tools/profiler version of
this but it wasn't implemented here.

Differential Revision: https://phabricator.services.mozilla.com/D220886
2024-09-16 21:09:33 +00:00
Nazım Can Altınova
f67f994dc2 Bug 1634785 - Fix how shared library names are found on linux and macOS r=mstange,profiler-reviewers
While testing the de-duplication on Linux and macOS, I noticed that the
symbolication was completely broken due to having incorrect library names in
libs array. They were always like: "<obj-dir>/dist/bin/libxul.so" instead of
"libxul.so". The library names are found from their paths, and apparently we
were using an incorrect path separator for Linux and macOS, "\" instead of "/".

Differential Revision: https://phabricator.services.mozilla.com/D220885
2024-09-16 21:09:32 +00:00
Nazım Can Altınova
c33b76893a Bug 1634785 - Make the base profiler shared libraries file closer to gecko profiler one r=mstange,profiler-reviewers
Again removing some unused/unneeded things so it's going to be easier to
deduplicate the files.

Differential Revision: https://phabricator.services.mozilla.com/D220883
2024-09-16 21:09:32 +00:00
Nazım Can Altınova
a1b72f21a4 Bug 1634785 - Add missing shared libraries methods to the baseprofiler implementation r=mstange,profiler-reviewers
These methods were already inside the shared libraries that was in
tools/profiler. Adding these methods here to make the implementations closer
and make the deduplication easier in the following commits.

Differential Revision: https://phabricator.services.mozilla.com/D220882
2024-09-16 21:09:32 +00:00
Mike Hommey
d46c6229a7 Bug 1917739 - Move Lz4 and mfbt/Compression* to mozglue/static. r=nika,frontend-codestyle-reviewers
As per mozglue/static/README:

> mozglue/static contains parts of the mozglue library that can/should be
> statically linked to e.g. js/Gecko.

The compression part of MFBT is a good candidate for this.

Differential Revision: https://phabricator.services.mozilla.com/D221565
2024-09-10 20:35:56 +00:00
Nicolas Guichard
5c37ebc381 Bug 1917744 - Adjust mozglue build script for rustc 1.83. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D221463
2024-09-10 03:35:01 +00:00
Florian Quèze
12e6021a2d Bug 1914862 - Add a TELEMETRY profiler cateogry, r=canaltinova,profiler-reviewers,aabh.
Differential Revision: https://phabricator.services.mozilla.com/D220132
2024-09-06 19:03:44 +00:00
Florian Quèze
757717524a Bug 1915228 - Remove expired telemetry scalar startup.skeleton_ui_disabled_reason, r=win-reviewers,TravisLong,gstoll.
Depends on D220334

Differential Revision: https://phabricator.services.mozilla.com/D220335
2024-08-28 19:44:36 +00:00
Matthew Gaudet
efe3f4bd3e Bug 1904429 - Extract some core logging types into their own header file r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D217873
2024-08-23 15:52:45 +00:00
Iulian Moraru
8cff16a948 Backed out 5 changesets (bug 1904429) for causing ThreadSanitizer linux tsan failures.
Backed out changeset 787f23230ebd (bug 1904429)
Backed out changeset 81e85421af01 (bug 1904429)
Backed out changeset 9bf9011b0736 (bug 1904429)
Backed out changeset a59511524bc7 (bug 1904429)
Backed out changeset e74a80333551 (bug 1904429)
2024-08-22 23:57:12 +03:00
Matthew Gaudet
6e50ad8063 Bug 1904429 - Extract some core logging types into their own header file r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D217873
2024-08-22 17:05:59 +00:00
Nika Layzell
d0b6b794db Bug 1908725 - Part 5: Add additional validation for early-startup command line checks, r=ipc-reviewers,mccr8
This patch adjusts the various places where we initialize content
processes to call SetGeckoProcessType as early as possible, and be more
consistent. After this change we should only ever set GeckoProcessType
and GeckoChildID once per-process (with the exception of the fork server
process).

In addition to this validation, some more checks around the fork server
were added, such as to prevent forking another forkserver, or forking a
non-content process.

As part of this change, there was some refactoring/cleanup done, such as
removing plugin-container.cpp and content_process_main, as compared to
the other duplicated code between the two call-sites, the duplication
was relatively small, and inlining it helped make things more readable.

Differential Revision: https://phabricator.services.mozilla.com/D218471
2024-08-07 20:39:41 +00:00
Nika Layzell
bdb401316d Bug 1908725 - Part 2: Make the ChildID available in the same places as OtherPid, r=ipc-reviewers,media-playback-reviewers,win-reviewers,alwu,rkraesig,gfx-reviewers,mccr8,nical
This requires quite a bit of piping to get the ChildID passed everywhere where
we currently pass the pid in IPC. This is done by adding a new struct type
(EndpointProcInfo), which is passed around instead of OtherPid in these places,
and contains the full pid.

In most cases, it was a fairly painless change to move over, however in some
cases, more complex changes were required, as the pid was being stored
previously in something like an Atomic<...>, and needed to be switched to using
a mutex-protected value.

In the future, it may be possible to remove OtherPid from IPDL actors once
everything is migrated to ChildID, but we're still a long way off from that, so
for now we unfortunately need to pass both around.

Differential Revision: https://phabricator.services.mozilla.com/D217118
2024-08-07 20:39:39 +00:00
Nika Layzell
008c780b6b Bug 1908725 - Part 1: Introduce GeckoChildID, r=glandium,ipc-reviewers,mccr8
The new GeckoChildID type introduced in this patch is inspired by the existing
ContentParentID type used by ContentParent, but is currently distinct. It is
supported by all process types at the GeckoChildProcessHost level and can be
read for the current process from anywhere.

As this type is similar in many ways to the process type, and should be
available as early as possible within child processes, this was added alongside
the GeckoProcessType value within mozglue to make that easier to do.

The type was chosen to be an int32_t to make it feel similar to a PID, which we
currently use for process identity comparisons across the codebase. The
intention is for GeckoChildID to be preferred for these within-gecko checks, as
these IDs will not be re-used and can be known earlier during child process
creation.

Differential Revision: https://phabricator.services.mozilla.com/D217117
2024-08-07 20:39:39 +00:00
c8ef
7a1a9c40a3 Bug 1911403 - fix typo in source code -> r=nalexander,profiler-reviewers,jandem,masayuki,canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D218474
2024-08-07 05:35:02 +00:00
Mike Hommey
27f6dc381c Bug 1909558 - Handle the deprecation of std::panic::PanicInfo. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D217533
2024-07-24 07:07:27 +00:00
Mike Hommey
f091d79808 Bug 1908833 - Remove unused #include <zlib.h>. r=geckoview-reviewers,m_kato
It hasn't been used since bug 855824.

Differential Revision: https://phabricator.services.mozilla.com/D217348
2024-07-23 22:05:38 +00:00
Mike Hommey
8e69a9a8fc Bug 1909344 - Adjust mozglue build script for rustc 1.82. r=firefox-build-system-reviewers,ahochheiden
Differential Revision: https://phabricator.services.mozilla.com/D217331
2024-07-22 22:33:32 +00:00
Sylvestre Ledru
45030f6970 Bug 1519636 - Reformat recent changes to the Google coding style r=emilio,necko-reviewers,geckoview-reviewers,application-update-reviewers,media-playback-reviewers,devtools-reviewers,anti-tracking-reviewers,profiler-reviewers,win-reviewers,migration-reviewers,padenot,mconley,nchevobbe,kershaw,gstoll,mstange,bytesized,m_kato
This new version of clang 17 also slightly changed the formatting.

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D215914
2024-07-17 11:15:31 +00:00
Ray Kraesig
ae1ea1e8fc Bug 1903452 - [1/2] Correct coordinate conversion when cloaking and clearing window r=emilio
The previous patchset failed to properly convert the RECT to be cleared
from screen- to window-coordinates. (This wasn't noticed because the two
only differ when nontrivial chrome such as the titlebar is present,
which by default it's not.)

Differential Revision: https://phabricator.services.mozilla.com/D214334
2024-06-25 18:19:42 +00:00
Jed Davis
db155d4dd8 Bug 1894073 - Suppress TSan false positive during an edge case in process launch. r=decoder,ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D212644
2024-06-18 13:47:52 +00:00
Ray Kraesig
799ee37eab Bug 1824053 - [4/4] cloak and clear new window before showing it r=win-reviewers,handyman
When creating the skeleton UI window, cloak and clear it to a theme-
appropriate color before first showing it, just as is done in nsWindow.

Differential Revision: https://phabricator.services.mozilla.com/D212764
2024-06-17 14:17:50 +00:00