2428 Commits

Author SHA1 Message Date
Darshan Sen
1c37daa5ac Reland "posix: Replace DoubleForkAndExec() with ForkAndSpawn()"
This is a reland of 460943dd9a71dc76f68182a8ede766d5543e5341

Original change's description:
> The DoubleForkAndExec() function was taking over 622 milliseconds to run
> on macOS 11 (BigSur) on Intel i5-1038NG7. I did some debugging by adding
> some custom traces and found that the fork() syscall is the bottleneck
> here, i.e., the first fork() takes around 359 milliseconds and the
> nested fork() takes around 263 milliseconds. Replacing the nested fork()
> and exec() with posix_spawn() reduces the time consumption to 257
> milliseconds!
>
> See https://github.com/libuv/libuv/pull/3064 to know why fork() is so
> slow on macOS and why posix_spawn() is a better replacement.
>
> Another point to note is that even base::LaunchProcess() from Chromium
> calls posix_spawnp() on macOS -
> 8f8d82dea0:base/process/launch_mac.cc;l=295-296

The reland isolates the change to non-Android POSIX systems because
posix_spawn and posix_spawnp are available in Android NDK 28, but
Chromium is building with version 23.

Change-Id: If44629f5445bb0e3d0a1d3698b85f047d1cbf04f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3721655
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-06-24 15:45:49 +00:00
Justin Cohen
6e946c4af8 Revert "posix: Replace DoubleForkAndExec() with ForkAndSpawn()"
This reverts commit 460943dd9a71dc76f68182a8ede766d5543e5341.

Reason for revert: This fails to compile in Chromium Android.
posix_spawn and posix_spawnp are available in Android NDK 28, but
Chromium is building with version 23.

https://ci.chromium.org/ui/p/chromium/builders/try/android_compile_dbg/1179765/overview

Original change's description:
> posix: Replace DoubleForkAndExec() with ForkAndSpawn()
>
> The DoubleForkAndExec() function was taking over 622 milliseconds to run
> on macOS 11 (BigSur) on Intel i5-1038NG7. I did some debugging by adding
> some custom traces and found that the fork() syscall is the bottleneck
> here, i.e., the first fork() takes around 359 milliseconds and the
> nested fork() takes around 263 milliseconds. Replacing the nested fork()
> and exec() with posix_spawn() reduces the time consumption to 257
> milliseconds!
>
> See https://github.com/libuv/libuv/pull/3064 to know why fork() is so
> slow on macOS and why posix_spawn() is a better replacement.
>
> Another point to note is that even base::LaunchProcess() from Chromium
> calls posix_spawnp() on macOS -
> 8f8d82dea0:base/process/launch_mac.cc;l=295-296
>
> Change-Id: I25c6ee9629a1ae5d0c32b361b56a1ce0b4b0fd26
> Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3641386
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Commit-Queue: Mark Mentovai <mark@chromium.org>

Change-Id: I7f6161bc4734c50308438cdde1e193023ee9bfb8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3719439
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-06-23 12:08:23 +00:00
Justin Cohen
23cefd0417 Fix Chromium compile.
Fixes error: invalid operands to binary expression ('std::ostream'
(aka 'basic_ostream<char>') and 'const char[19]') << "pthread_setname_np";

in test/scoped_set_thread_name_posix.cc

Change-Id: I77eeeee9c828d563aaa15331733001e522a04642
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3714964
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-06-23 03:28:39 +00:00
Justin Cohen
21546d8514 Use call_once in lazy settings load.
This fixes a test case that accesses settings for the first time in
multiple threads simultaneously.

Fixed: crashpad:417
Change-Id: I6539682f171563f8ff5a1203fdd550ab92afc276
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3711807
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2022-06-22 17:22:19 +00:00
Nico Weber
7c30a508eb Build actual crashpad .asm files in win/cross builds
Now that we have llvm-ml, we no longer need the workaround for this.

This upstreams
https://chromium-review.googlesource.com/c/chromium/src/+/3708412

Bug: chromium:762167
Change-Id: Iadc8ba9753bb7dd079415ee744f3b176b7e2f629
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3707748
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-06-17 13:48:37 +00:00
Darshan Sen
460943dd9a posix: Replace DoubleForkAndExec() with ForkAndSpawn()
The DoubleForkAndExec() function was taking over 622 milliseconds to run
on macOS 11 (BigSur) on Intel i5-1038NG7. I did some debugging by adding
some custom traces and found that the fork() syscall is the bottleneck
here, i.e., the first fork() takes around 359 milliseconds and the
nested fork() takes around 263 milliseconds. Replacing the nested fork()
and exec() with posix_spawn() reduces the time consumption to 257
milliseconds!

See https://github.com/libuv/libuv/pull/3064 to know why fork() is so
slow on macOS and why posix_spawn() is a better replacement.

Another point to note is that even base::LaunchProcess() from Chromium
calls posix_spawnp() on macOS -
8f8d82dea0:base/process/launch_mac.cc;l=295-296

Change-Id: I25c6ee9629a1ae5d0c32b361b56a1ce0b4b0fd26
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3641386
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-06-16 13:42:26 +00:00
Mark Mentovai
07ef17371d Add buildtools/clang_format/script to DEPS
clang-format doesn’t work after week’s buildtools update to 0a14d52dad27
without separately checking out buildtools/clang_format/script.

Change-Id: I8330aacb85d1ba96318e5f2cd4563b6d32615963
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3707851
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
2022-06-15 14:54:13 +00:00
Mark Mentovai
3ae34b169b [test] Fix test build failures in Chromium
Importing Crashpad into Chromium revealed a few build failures:

1) The MSVC compiler needed assistance constructing SleepingThreads

2) scoped_set_thread_name_posix.cc did not build on Android, where
   BUILDFLAG(IS_LINUX) is not defined and __ANDROID_API__ must be
   set to 24 or higher to use pthread_getname_np()

This fixes the build failures, which I tested with a Chromium CQ
dry-run:

https://crrev.com/c/3703491

Change-Id: Ibde7cacaa45d384272890ea9b1ee2d707048ab03
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3703446
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-06-15 00:49:56 +00:00
Ben Hamilton
02bdf8f9d7 [snapshot] Add missing #include in process_reader_win_test.cc
The Chromium presubmits flagged a missing #include in
process_reader_win_test.cc.  This adds the missing #include.

Change-Id: I68aed4328f976bba547a0cb7a9ea833fdf71873b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3703312
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-06-14 20:01:06 +00:00
Alex Pankhurst
f19ef3c607 [fuchsia] Fix uninitialized fields
Fuchsia's Crashpad roller was broken due to uninitialized fields in
structs.

Bug: fxbug.dev/101498
Change-Id: I1283afea9c5ac4eddb432590f9a5ec5cb1856a7c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3704517
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Pankhurst <pankhurst@google.com>
2022-06-14 19:07:22 +00:00
Clemens Backes
2bf08e6223 Detect blocked signal installation by sanitizers
Sanitizers can prevent the installation of signal handlers, but
sigaction would still return 0 (for success). Detect this by checking
the installed signal handler via a second call to sigaction.

R=mark@chromium.org

Bug: chromium:1328749
Change-Id: I62a5777379ec5c6b1ca2d5a62e7cd3fb8ed1437b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3702302
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
2022-06-14 14:25:29 +00:00
Ben Hamilton
ed8cfeb2cd [snapshot] Add support for thread names
This CL adds a new method ThreadSnapshot::ThreadName(), implements
it in each snapshot implementation, and adds tests for iOS, macOS,
Linux, Windows, and Fuchsia.

Bug: crashpad:327
Change-Id: I35031975223854c19d977e057dd026a40d33fd41
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3671776
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Ben Hamilton <benhamilton@google.com>
2022-06-13 20:58:37 +00:00
Mark Mentovai
0a14d52dad Update buildtools (gn and clang-format)
This updates buildtools to 8b16338d17cd. gn has migrated out of
buildtools and into its own cipd package, so gn is pulled at
2ecd43a10266 (current). This provides a mac-x86_64 or mac-arm64 gn as
appropriate for the host CPU architecture. The buildtools update also
brings distinct clang-format executables for mac-x86_64 and mac-arm64 as
appropriate.

Change-Id: I4162b093cfe8d5a2ba66ba62f6462813ea489dbd
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3700190
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
2022-06-10 15:34:13 +00:00
Justin Cohen
816c5572b8 Lazy load settings in CrashReportDatabase.
Before this patch, settings.dat is read from and written to during
database initialization. This happens within Crashpad for iOS, and
within Chrome during startup here:
https://source.chromium.org/chromium/chromium/src/+/main:components/crash/core/app/crashpad.cc;l=209
These are blocking calls on the main thread.

CrashReportDatabaseMac::Initialize will still fail if the various
directory create/ensure calls fail.

Change-Id: Ic665884d1f41caa853aba9b29b6fb2c14b2cda15
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3674639
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-06-09 13:41:43 +00:00
Ben Hamilton
339b125241 [minidump] Fix unaligned pointer in thread name list
https://crrev.com/c/3671775/ introduced a warning (and thus, a
compilation failure) on 32-bit ARM when taking the address of the RVA64
field MINIDUMP_THREAD_NAME::RvaOfThreadName:

minidump/minidump_thread_name_list_writer.cc:57:23: error: taking address of packed member 'RvaOfThreadName' of class or structure 'MINIDUMP_THREAD_NAME' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
  name_->RegisterRVA(&thread_name_.RvaOfThreadName);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Indeed, MINIDUMP_THREAD_NAME's RvaOfThreadName field is not aligned,
so the technique used in MinidumpWritable::Register*() of passing in a
rawptr to an arbitrary struct field which is later dereferenced cannot
be used for this field.

This CL replaces the use of MinidumpWritable::Register*() with
overriding MinidumpThreadNameWriter::WillWriteAtOffsetImpl() to
directly calculate and assign thread_name_.RvaOfThreadName.

Change-Id: I71e751a5b5e896b5e7277879bdbdff6e9eefe023
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3693846
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Ben Hamilton <benhamilton@google.com>
2022-06-08 18:52:32 +00:00
Justin Cohen
0662aeb83e Fix usage of sprintf.
sprintf is marked as deprecated with Xcode 14.

Bug: 1331345
Change-Id: I600372d270272348d6c114112e9d7d71e75bc091
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3688301
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-06-07 04:02:13 +00:00
Ben Hamilton
6d0d1a4be6 [minidump] Add support for THREAD_NAME_LIST stream
The minidump stream type MINIDUMP_THREAD_NAME_LIST represents
thread names as a list in the form [(thread_id, thread name), ...].

This introduces a new MinidumpThreadNameListWriter class which
allows OS-specific snapshot writers to write thread names using
this new stream type.

Bug: crashpad:327
Change-Id: Ief45df5dbbf44c0e1254786bfbe6720112ceef38
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3671775
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
2022-06-06 19:39:09 +00:00
Ben Hamilton
91cec09d93 [minidump] Extend minidump string writer support for RVA64 strings
To support MINIDUMP_THREAD_NAME_LIST (which uses 64-bit RVAs for the
thread name MINIDUMP_STRING), this adds minidump string writing and
reading support for the new 64-bit RVA64 and
MINIDUMP_LOCATION_DESCRIPTOR64 types.

Bug: crashpad:327
Change-Id: Iffefffef358517dfc6deac02051dff9dbb8eb214
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3673779
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
2022-06-02 18:46:16 +00:00
Alex Pankhurst
fc0b157a8e [fuchsia] Fix build errors on Fuchsia
Fuchsia's Crashpad roller was failing due to 'std::size' not being found
and struct fields not being initialized (detected by
-Wmissing-field-initializers)

- Fix 'std::size' issue by using a std::array instead of a plain C array
- Fix missing initializers with default values

Bug: fxbug.dev/101498
Change-Id: I75fa54d5c1730772b1af1be31c64b0cc58886a90
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3687239
Commit-Queue: Alex Pankhurst <pankhurst@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-06-02 17:55:15 +00:00
Ben Hamilton
a903f7541f [minidump] Add support for RVA64 / MINIDUMP_LOCATION_DESCRIPTOR64
Newer minidump stream types, like MINIDUMP_THREAD_NAME_LIST, use
64-bit RVAs (which have 64-bit location descriptors) instead of 32-bit
RVAs and location descriptors.

This adds support to MinidumpWritable for the new 64-bit RVA64 and
MINIDUMP_LOCATION_DESCRIPTOR64 types.

Bug: crashpad:327
Change-Id: Icd67bca600756a68ef9ba7d5a429f935eebf726f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3673776
Commit-Queue: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-06-01 19:13:07 +00:00
Ben Hamilton
b1ffe93562 [ios] Fix two shutdown races
There were two shutdown races in the iOS Crashpad client:

1) MachMessageServer::Run can return either MACH_RCV_PORT_CHANGED *or*
   MACH_RCV_INVALID_NAME based on the timing of when the port is
   closed, for example:
   c21f7bab5c/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift (L131)
2) The iOS crashpad::CrashHandler thread could read from its member
   variable mach_handler_running_ while another thread wrote to it

Change-Id: I696ece8575d9b88cbd0593e7c479bd4c7f863f45
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3651395
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-05-24 18:15:58 +00:00
Peter Kasting
5f2a706f71 Blind attempt to fix compile failure in latest roll.
Bug: none
Change-Id: Iea44283cf4df029b595e87bb42b57422e310e7a4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3659054
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
2022-05-23 04:44:26 +00:00
Peter Kasting
13a1e171eb C++20 build fixes.
* ATOMIC_FLAG_INIT is deprecated.
* Compound ops on volatiles are deprecated.

Bug: chromium:1284275
Change-Id: I2235662c00e4be8c5eba2aaf565663faf8d9576a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3658639
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-05-22 01:13:35 +00:00
Mark Mentovai
c5094b99a4 minidump: Size the annotation list writer iovec more carefully
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/731309/6#message-19ebbbfb10fa499bb00989728b19756982641326

Change-Id: I274eb62bdc9b0039196dc01902eb8654154a8c1a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3654638
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2022-05-20 17:37:04 +00:00
Ben Hamilton
55de7bb48e [Crashpad/Annotations] Increase maximum annotation name length to 256
Crashpad annotation names are currently limited to 64 bytes.

Breakpad supports up to 256 bytes, so for compatibility with existing
clients, this increases the maximum annotation name size from 64 to
256 and adds new tests to confirm the maximum name and value sizes.

Change-Id: Ib7954bea96046b6b7e18ed9743fe2a15dd3dabac
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3655975
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
2022-05-19 21:23:53 +00:00
Ben Hamilton
2071abaeb4 [ios] Fix FD leak in IOSIntermediateDumpWriter
IOSIntermediateDumpWriter::Close() is intended to close the FD opened
by the in-process handler.

Currently, InProcessHandler::ScopedLockedWriter::~ScopedLockedWriter() does invoke IOSIntermediateDumpWriter::Close().

However, InProcessHandler::Initialize() invokes the utility CreateWriterWithPath() which directly creates an IOSIntermediateDumpWriter. It neither uses ScopedLockedWriter nor invokes Close().

This fixes the issue by:

1) Making IOSIntermediateDumpWriter::~IOSIntermediateDumpWriter() DCHECK() that it's closed
2) Calling IOSIntermediateDumpWriter::Close() from InProcessHandler::~InProcessHandler() and from test files

Change-Id: Ibfede0a3d2aeac948c7ff3d56445e13d1a4028b5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3648710
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
2022-05-18 19:25:09 +00:00
Alex Gough
1fa6eb27f6 Fix compile for arm64
Some xstate flags are not available in arm64 as it does not have
xstate so we should omit the InitializeXState method on the
`target_cpu = arm64` configuration.

Bug: 1250098
Change-Id: I5c92d6efbe90587bdebef87d4a6ce4e9b25afa4d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3653575
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-05-18 17:16:59 +00:00
Alex Gough
d8567ffc53 Capture shadow stack region if available
Where shadow stacks are available, capture the entire shadow stack page
unconditionally.

Bug: 1250098
Change-Id: I5e2273c19b5f2d571195ff1252396df7dd70566a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3493684
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-05-17 03:59:48 +00:00
Alex Gough
9ef737a26d Captures shadow stack registers for x64 Windows contexts
Windows extended contexts must be allocated by InitializeContext2 and
may not be aligned. This means we cannot simply store a struct in
our thread snapshot object, but must instead store enough memory
and alias our struct onto this backing memory.

Note that shadow stack pointers are not yet recorded for the initial
exception - this cannot be determined using LocateXStateFeature in
the capturing process and will be added in a future CL by plumbing
through client messages when a crashed process requests a dump.

See crash/32bd2c53a252705c for an example dump with this baked into
chrome, that has passed through breakpad without breaking it. Local
testing shows this creates valid dumps when built into Chrome, but
that the referenced memory limits may need to be increased to allow
for ssp referenced memory to be included.

See "MANAGING STATE USING THE XSAVE FEATURE SET" Chapter 13 in the
Intel SDM[0]. Many of the offsets and sizes of the extended features
are provided by cpu specific values. We can access these in Windows
using the SDK, and transfer these to the saved extended context
which in turn is understandable by windbg.

Further information is available from AMD Ch. 18 "Shadow Stacks"[1].

    [0] https://software.intel.com/content/www/us/en/develop/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4.html.
    [1] https://www.amd.com/system/files/TechDocs/24593.pdf

Bug: 1250098
Change-Id: I4b13bcb023e9d5fba257044abfd7e251d66a9329
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3300992
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2022-05-17 03:39:16 +00:00
Alex Gough
9e0051aba6 Write compacted xsave contexts in minidumps
Adds new structures and offsets for minidump extended contexts. This
information will be captured from threads in a later CL so this CL
does not yet write different dumps, except in testing.

Minidump format for extended compacted contexts has been determined by
experiment. Offsets for where to write various parts of the context
are hardcoded to 0x550 as this matches values seen in Windows. Offsets
for misc_info_5 match those seen in working minidumps that can be opened
in windbg. Our hope is that while these could change in future, CPU
and OS vendors are unlikely to change them.

See doc[0] for a discussion of these fields and offsets in the minidump.

See "MANAGING STATE USING THE XSAVE FEATURE SET" Chapter 13 in the
Intel SDM[1]. Many of the offsets and sizes of the extended features
are provided by cpu specific values. We can access these in Windows
using the SDK, and transfer these to the saved extended context
which in turn is understandable by windbg.

Further information is available from AMD Ch. 18 "Shadow Stacks"[2].

    [0] https://docs.google.com/document/d/1Dn8n97r5B7kxYouvujNnPIYd_7QeVHpahSRmB92Qn6g/edit#heading=h.hivqj2jg39y
    [1] https://software.intel.com/content/www/us/en/develop/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4.html.
    [2] https://www.amd.com/system/files/TechDocs/24593.pdf

Bug: 1250098
Change-Id: Ia9041acc379c6d38329ee99737a2a0a77f7a1ee0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3536964
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2022-05-17 01:45:56 +00:00
Alex Gough
25222891c7 Add fields for shadow stack registers to x64 snapshot
This will be used in a later CL to shuttle shadow stack information
from capture to minidumps. For now these fields are zeroed and have
no effect on any platform.

The x64 snapshot context we use no longer directly maps to the early
CONTEXT structure used by Windows (the prelude still matches). This
may cause confusion if people use the size of a snapshot context when
they meant to use sizeof(CONTEXT).

Bug: 1250098
Change-Id: Idac7d888b9e606ceb250c4027e0e7f29f4c0a55f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3536963
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2022-05-17 01:12:26 +00:00
Alex Gough
a5b7e504c6 Thread snapshots on Windows can have varying size
In a future CL we will make use of InitializeContext2 which can produce
contexts of varying sizes - this makes the existing use of a union for
wow/x64 contexts no longer feasible.

The context union in process_reader_win is replaced with a (moveable,
copyable) helper struct which currently only knows how to allocate
the replaced WOW or CONTEXT sized unions.

As this field is no longer a member of the Thread struct it cannot
be passed into other functions as a reference, so instead a pointer
is used in these functions.

Bug: 1250098
Change-Id: Ied3fe971c0073bbdafc071217e1bb0f72350bb4e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3538668
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-05-17 00:40:26 +00:00
Justin Cohen
4581a355b1 ios: Limit depth of intermediate dump parser.
Limit the parser stack to 10 to prevent malformed intermediate dumps
from causing a stack overflow.

Bug: 1321382
Change-Id: I880e80de585b0fb18f0c383102b9227d6ffbfa76
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3637719
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-05-11 16:24:00 +00:00
Justin Cohen
94242690d5 ios: Check dyld_image_info->imageFilePath for nullptr.
It seems on iOS 14, sometimes this path can be empty. Passing nullptr
to strlen will crash. Also fixes an incorrect file path length for
the dyldPath.

Bug: 1323905
Change-Id: Idf1ef9e0165853a5d57d272896a40bf0b30a3368
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3637717
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-05-11 00:07:20 +00:00
Justin Cohen
34a090b573 ios: Capture more exceptionReason in exception processor.
This brings Crashpad in line with what Breakpad captures.

Change-Id: I8ce2d81fc9cb150dc9817034fac3516f27f5661b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3611069
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-05-10 21:14:00 +00:00
Peter Kasting
dfb3b59660 In C++20, atomics are value-initialized by default.
ATOMIC_FLAG_INIT is thus deprecated.  Feature-test for this.

Bug: chromium:1284275
Change-Id: I000d9d8ba5248bf72390b25b2165094faf5aa3db
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3629949
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-05-09 18:39:09 +00:00
Justin Cohen
55cee0127e ios: Don't start upload thread from background.
It is not safe to start the upload thread when in the background (due
to the potential for flocked files in shared containers).

Bug: 1317812
Change-Id: Ie476c2ccbc7232bc9e1a30a7a497128a4248c39e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3595621
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-20 18:22:30 +00:00
Joshua Peraza
94ea6d6f30 Remove ELF headers
Bug: b/180059624
Change-Id: I9db01233114d223c2f90e26267622650c9115484
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3597630
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2022-04-20 18:04:10 +00:00
Justin Cohen
12cb55fecf ios: Safely handle database errors when saving crash reports.
Bug: 1317298
Change-Id: Iac4050fc4ec61f391bab85c4d8ac97fd8e898f14
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3591013
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-19 22:27:59 +00:00
Justin Cohen
8647761c7d ios: Ensure ScopedLockedFileHandle and UploadReportMac destructor order.
Followup to crrev.com/c/3573184, which did not honor destructor order,
leading to the background task releasing before the lock.

Bug: 1313555
Change-Id: Ifbd3902964552458b83cfc550f50058067021499
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3591012
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-19 22:26:19 +00:00
Alex Gough
36c88b15b7 Initializes contexts on ios x64 builds
In a later CL, in some cases these structs were not zero-initialized
which caused some iOS tests to fail.

We now zero-initialize these structs which should be harmless now,
and useful later.

Bug: 1250098
Change-Id: I933e80e56714a1d8988deae3aa56ec36ed98ef03
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3538665
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2022-04-18 22:36:49 +00:00
Justin Cohen
68aba08c48 ios: Don't block main thread on suspend.
Because the upload thread uses synchronous upload, calling Stop() on
that thread from the main thread will lock, and trigger a terminate
when transitioning from foreground to background.

Additionally, background assertions now only last 30 seconds, so
shorten the timeout to 20 seconds.

This is a followup to https://crrev.com/c/3517967.

Bug: crashpad:1315441
Change-Id: Ic6886607805667ffce5ecf41716fc63333a341b8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3577820
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-12 14:01:16 +00:00
Justin Cohen
646bba733b ios: Add ScopedBackgroundTask to more flock file access.
Use ScopedBackgroundTask to prevent file lock termination from happening
when holding locked files in a shared AppGroup.

Bug: 1313555
Change-Id: Idc0105f8ecdb65c26214a7265a216b9d480ed01d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3573184
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-11 17:00:48 +00:00
Joshua Peraza
f882d2af82 Add root_gen_dir to crashpad_config
Follows up on discussion in:
https://groups.google.com/a/chromium.org/g/crashpad-dev/c/1-QgplOJnw8

Change-Id: I6def168182f5d3219db4691d4b81ea508fd08a85
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3577803
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2022-04-08 20:13:16 +00:00
Joshua Peraza
e180670cb5 Add libcurl to required packages in documentation
Follows up on discussion in:
https://groups.google.com/a/chromium.org/g/crashpad-dev/c/1-QgplOJnw8

Change-Id: Ibb6bfca0455f34f23b6d833c4b67fd392eee74ca
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3579505
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2022-04-08 19:40:46 +00:00
Sylvain Defresne
7bc7e7508f Fix flaky noop build failure of crashpad
Linking crashpad (//third_party/crashpad/crashpad:util) target
into a target built for a secondary toolchain could cause noop
build failure because of an incorrect `include_dirs` directive.

The library depends on a generated buildflag, which when in a
secondary toolchain is generated to $root_gen_dir, a directory
that includes the toolchain name (except for the primary one).

The target added $root_build_dir/gen to its `include_dirs`
which is equal to $root_gen_dir for the primary toolchain, but
distinct for secondary toolchain.

Moreover, `include_dirs` define directly in a `source_set` are
placed before any `include_dirs` values inherited from configs.
This means that $root_build_dir/gen was before $root_gen_dir in
the list ($root_gen_dir is inherited from default config when
building Chromium).

The result is that building any crashpad files would result in
them trying to first include the version of the buildflag that
was generated for the primary toolchain, and if not found, using
the correct one. This was then recorded in the depfile generated
by the compiler.

This meant that it was possible for the build to be incorrect
(as the content of the buildflag may be different between the
two toolchains) and cause flaky noop failures (as the buildlag
generation for the primary toolchain and the compilation of
the source file for the secondary toolchain are unordered, but
a dependency was recorded via the depfile leading ninja to
report a dirty build).

The fix is simple, use the correct value $root_gen_dir in the
`include_dirs` directive.

Fixed: chromium:1314711
Change-Id: Icba521313e4105713e66fa576d730b00c7e74c21
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3579401
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-08 15:07:36 +00:00
Justin Cohen
fa01762894 ios: Update build scripts to support Apple Silicon simulators.
Also update mini_chromium to 5654edb422 for target_environment arg.

Change-Id: If350938bbeaddbdda123c2f0e9ff978075a60370
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3558170
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-31 18:03:02 +00:00
Justin Cohen
20d6dee037 Roll crashpad/third_party/googletest/googletest/ 5bcd8e3bb..af29db7ec (148 commits)
5bcd8e3bb9..af29db7ec2

$ git log 5bcd8e3bb..af29db7ec --date=short --no-merges --format='%ad %ae %s'
2022-03-23 absl-team Address deprecation warning surfaced by Github presubmit tests
2022-03-23 mattias.ellert Split gmock-matchers_test into 4 smaller test #3653
2022-03-22 absl-team Only print disabled test banner if the test matches gtest_filter
2022-03-21 absl-team Clarify public access on gmock examples.
2022-03-18 bmesser Remove sanity as it is offensive to neurodiverse individuals.
2022-03-15 absl-team Running clang-format over all of GoogleTest
2022-03-14 dinor Remove references to deleted script gen_gtest_pred_impl.py
2022-03-08 absl-team Mark ACTION_Pn()-generated functions as must-use-result, adding non-compilation tests.
2022-03-08 sobik.szymon Add myself to contributors
2022-03-08 sobik.szymon Adjust documentation regarding xml and json source file location otput.
2022-03-08 sobik.szymon Adjust xml and json unit tests to test for source file and line location.
2022-03-08 sobik.szymon Add support for testing of xml and json output of source file and line location
2022-03-08 sobik.szymon Output source file path and line number in xml and json files.
2022-02-17 dmauro Update GCC/Clang Linux tests to use Bazel 5.0.0
2022-02-14 absl-team Address conversion warning by explicitly casting to size_t
2022-02-09 absl-team Add a 3-arg overload for ResultOf() matcher that takes a description string for better error messages.
2022-02-05 hgsilverman Apply requested changes by using std::inserter with move.
2022-02-05 noiseless-ak Fix gtest-help-test failure on OpenBSD
2022-02-01 absl-team GetCurrentOsStackTraceExceptTop (both the method of UnitTestImpl and the wrapper function in gtest.cc) rely on the fact that the inner call is not getting optimized. This CL annotates them with the appropriate attributes.
2022-01-29 hgsilverman Do constant time matching for exact match filters.
2022-01-28 dmauro Finish some missed pieces of the TestCase to TestSuite Migration
2022-01-26 dinor Change `ReturnArg` to use perfect forwarding of arguments (#3733)
2022-01-25 melroy Let me give a change to try it again - updating to latest version
2022-01-24 absl-team Make recreate_environments_when_repeating=false the default.
2022-01-19 absl-team Factor out AssertionResult into dedicated gtest-assertion-result header + implementation files to prevent cyclic includes between gtest.h and gtest_pred_impl.h
2022-01-18 absl-team Consistently apply IWYU pragmas across googletest and googlemock headers
2022-01-14 dinor Fix reference to source file in gmock FAQ
2022-01-14 dmauro Update test Docker image to GCC 11.2, Clang 14 (prerelease), CMake 3.22.1, and Bazel 4.2.2
2022-01-13 ayush854032 FIX #2174 -- remove `DEBUG_POSTFIX`
2022-01-12 absl-team Fix run-on sentence
2022-01-06 hgsilverman Fix a typo in comments.
2021-12-22 hgsilverman Use normal for loop instead of accumulate.
2021-12-17 hgsilverman Improve code readablity.
2021-12-17 hgsilverman Apply requested changes to preserve old behavior.
2021-12-03 hgsilverman Reimplement MatchesFilter with new interfaces.
2021-11-23 hgsilverman Apply requested changes.
2021-10-17 hgsilverman Get rid of redundant filter matching code
2021-10-17 hgsilverman Add comments describing the behavior of filters
2021-10-17 hgsilverman Process filter string once instead of per test
2022-01-05 bsilver16384 Remove another GTEST_DISALLOW_ASSIGN_ that crept in
2022-01-05 73706994+jjfvanderpol Set CMake Policy CMP0077 to NEW
2022-01-04 4789010+ramkumar-kr Update example to reflect the tests below
2022-01-01 ayush854032 FIX #3719 -- Fix `clang` conversion warnings
2021-12-27 absl-team Include the param names in the generated description of the MATCHER_P matchers.
2021-12-22 absl-team Clarify "package" means "Bazel package", and promote `testonly=True` rather than `testing` sub-directory.
2021-12-22 dmauro Makes the Python imports consistently use full paths from the repository root, unifying the behavior between Bazel and CMake
2021-12-21 dmauro Makes TestForDeathTest.CRTDebugDeath only run when _DEBUG is defined
2021-12-21 philip.j.m link to regex on qnx in cmake
2021-12-15 dinor Release tests for UnitTestOptions::MatchesFilter
2021-12-07 absl-team Add NOLINT to address modernize-use-trailing-return-type in TEST_F uses
(...)
2021-09-14 absl-team Googletest export
2021-09-15 761129+derekmauro Revert grammatically incorrect change
2021-09-10 absl-team Googletest export
2021-08-20 absl-team Googletest export
2021-08-20 absl-team Googletest export
2021-08-19 invalid_ms_user Simplify example code with c++11
2021-08-12 absl-team Googletest export
2021-08-10 dmauro Googletest export
2021-08-09 dmauro Googletest export
2021-08-10 akashkumarsingh11032001 add a missing 'a'
2021-08-10 akashkumarsingh11032001 Create CONTRIBUTING.md
2021-08-06 absl-team Internal change
2021-08-06 victordk13 Format test properties in xml printer
2021-08-05 iamberkeyavas typo fix gmock_cook_book
2021-08-03 absl-team Googletest export
2021-08-03 absl-team Googletest export
2021-08-02 absl-team Googletest export
2021-07-29 absl-team Googletest export
2021-07-29 otnaiud Typo, double "the"
2021-07-28 absl-team Internal change
2021-07-24 slowy.arfy fix: typo codespelling comment
2021-07-22 absl-team Googletest export
2021-07-21 absl-team Googletest export
2021-07-19 dmauro Googletest export
2021-07-14 761129+derekmauro Fix location of GOOGLETEST_CM0011 marker
2021-07-08 absl-team Googletest export
2021-07-08 absl-team Googletest export
2021-07-07 absl-team Googletest export
2021-07-02 absl-team Googletest export
2021-07-02 absl-team Googletest export
2021-07-07 manuel Link -lregex on QNX
2021-07-01 jeremy.nimmer Use GTEST_DONT_DEFINE_TEST_F to guard TEST_F
2021-06-29 absl-team Googletest export
2021-06-28 absl-team Googletest export
2021-06-28 absl-team Googletest export
2021-06-25 manuel Don't link pthread on QNX
2021-06-23 alex Fix EXPECT_DEATH() and ASSERT_DEATH() triggering -Wcovered-switch-default
2021-06-18 dmauro Googletest export
2021-06-03 pochkaenkov feat: make a matcher ElementsAreArray applicable for std ranges
2021-06-13 hyuk.myeong fix typos
2021-06-11 absl-team Googletest export
2021-06-10 absl-team Googletest export
2021-06-09 absl-team Googletest export
2021-06-09 dmauro Googletest export
2021-06-09 absl-team Googletest export
2021-06-09 absl-team Googletest export
2021-06-08 absl-team Googletest export
2020-12-30 mattias.ellert Port to GNU/Hurd
2020-12-29 julien.jemine Using auto instead of container::const_iterator
2020-12-24 georgthegreat Use proper feature test macro to test if library supports char8_t

Created with:
  roll-dep crashpad/third_party/googletest/googletest

Change-Id: I34a2d997498b73a17ee9ee71db45081f2ebab9a4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3553800
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-26 02:42:15 +00:00
Justin Cohen
facfdb9e53 Roll crashpad/third_party/edo/edo/ 6ffbf8331..727e55670 (28 commits)
6ffbf83317..727e556705

$ git log 6ffbf8331..727e55670 --date=short --no-merges --format='%ad %ae %s'
2022-03-24 strangewiz Fix up EDO with -Wunused-but-set-variable warning turned on. (#244)
2022-03-14 ynzhang Internal test update only.
2022-03-14 ynzhang Test update only.
2022-02-03 albertbow eDO won't block the object encoding if the object is passed by value.
2021-11-12 albertbow Change EDOHostService.keepDeviceConnection to readwrite and atomic.
2021-11-10 albertbow Change internal-only property from "readwrite/atomic" to "readonly/nonatomic".
2021-11-09 no-reply Add appropriate nonatomics to properties so we can enable `-Wimplicit-atomic-properties`
2021-11-07 no-reply Fix up EDO with `-Wbad-function-cast` warning turned on.
2021-11-07 no-reply Fix up EDO with `-Warc-repeated-use-of-weak`
2021-10-27 ynzhang Invalidate the host service before resetting the service map.
2021-10-25 albertbow Add reconnection logic if eDO host is constructed via device connection.
2021-10-18 ynzhang Fix an issue of encoding for some targets.
2021-08-06 haowoo Update to Xcode 12.5 and clean up Travis.
2021-07-09 mobile-devx-github-bot Don't prevent passing NULL to non-Objective-C pointer parameters.
2021-05-25 albertbow Correct return value of eDO class request to be nullable.
2021-04-29 albertbow Upgrade eDO deployment os target to 11.0.
2021-04-29 albertbow Create helper class to pass Codable pure Swift types through a remote call.
2021-04-28 albertbow Bump Travis xcode version to 12.0.
2021-03-12 albertbow Avoid always creating listening port on the temporary service.
2021-03-11 albertbow Clean up IWYU warnings for eDO code base.
2021-03-05 albertbow Adds one more test case for deadlock fix.
2021-03-04 albertbow Fix the deadlock caused by recursive eDO call from temporary host service.
2021-02-10 mobile-devx-github-bot Internal Change.
2021-01-14 tirodkar Update eDO comments.
2020-12-17 albertbow Fix remote invocation failure on EDOObject wrapped EDOWeakObject.
2020-12-09 albertbow Upgrade CHANGELOG and podspec for eDO 1.0.2 release.
2020-11-23 haowoo Retrieve block signatures directly from block headers.
2020-11-21 mobile-devx-github-bot Add signature to blocks in EDO

Created with:
  roll-dep crashpad/third_party/edo/edo

Change-Id: I1fbb78652893e6f334e22902b3bafe4df9d3f173
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3550546
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-25 22:38:13 +00:00
Justin Cohen
4ead15ad86 ios: Fix googletest compile with latest Xcode.
Ignore gmock-matchers_test.cc deprecated std::iterator.

Change-Id: I008d7fc8bde34653d6bde8046875edfc5660f606
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3550545
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-25 22:37:17 +00:00