This better ensures that using code like
`NTSTATUS_LOG(ERROR, status) << ::GetLastError()` would print the
intended value. This isn't done today by the code AFAICT, but
making this change primarily for consistency with the change to
Chromium logging in
https://chromium-review.googlesource.com/c/chromium/src/+/5443628
Bug: chromium:333445539
Change-Id: I49f16b9ed78d98a0b2f178f58465002aad757ae5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5474027
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Andrew Williams <awillia@chromium.org>
Replacing std::is_pod usage as per the following compilation error:
```
../../util/misc/uuid.cc:44:20: error: 'is_pod<crashpad::UUID>' is deprecated: use 'is_standard_layout && is_trivial' instead [-Werror,-Wdeprecated-declarations]
static_assert(std::is_pod<UUID>::value, "UUID must be POD");
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/type_traits:818:5: note: 'is_pod<crashpad::UUID>' has been explicitly marked deprecated here
_GLIBCXX20_DEPRECATED_SUGGEST("is_standard_layout && is_trivial")
```
Bug: None
Change-Id: I1d61ee12261877f7f1f84f0ea15d262d22959766
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5472885
Commit-Queue: Andrew Williams <awillia@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This DCHECK() was not correct. When dumping a process with CET
enabled the cetumsr and cetussp registers are not available in
the context obtained for the exception record. All contexts to be
written to a minidump must have the same context format so those
registers will be present for captured threads. It is therefore ok for
the context to expect extended xsave registers but for them to be
zero in some cases.
Bug: 337665168
Change-Id: If7e5f40fe8eda6799b034991cb87e89437cb4821
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5507588
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
base/sys_byteorder.h is going away. Instead, use the byte conversions
in base::numerics to convert from a byte array in big endian to an
integer. This avoids putting big endian data into integer types at all.
mini_chromium was rolled and crashpad updated to work with newer
mac/windows toolchains in order to support C++20 in
f9cee5c147db30dc8fa1a048aabd165965b5cb60.
Bug: 40284755
Change-Id: If690847b7aa54b0216e73ec297eae3d0bca2fa57
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5402184
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
There were two issues with the iOS implementation of CrashpadClient
which I reported in https://crbug.com/crashpad/481:
1) TSAN found a data race in ResetForTesting() when it modified the
ScopedMachReceiveRight while the Mach exception port thread was
reading it
2) The Mach port connected to the exception server was never deallocated
This CL fixes both issues.
Change-Id: I5bd4f79ae6d0eccca954d663be7a36f8ceb0a0e8
Bug: https://crbug.com/crashpad/481
Bug: b:332305593
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5410301
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Also enables C++20 as span now depends on it.
Roll buildtools to grab a newer libc++ that supports C++20.
Explicitly capture `this` in lambdas in cpp-httplib as the implicit
capture through `=` is deprecated and causes an error in C++20.
Update the MacOS version to "Mac-13|Mac-14" which is the current
value of `os.MAC_DEFAULT` in Chromium infra in order to have
C++20 support in the std library on iOS.
Moves iOS tests to run on iPhone 13 and includes a mini_chromium roll
to fix Xcode 14.3 egtests.
Bug: 40284755
Change-Id: Ic078f07d12473f2aaed5e84df0f0a7fb7b8c35c3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5443384
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
This should give crashpad a newer xcode and msvc that support C++20.
These changes need to land separately from the C++20 usage, as they do
not get applied until after landing, so can't affect the CQ from inside
the CQ.
Bug: 40284755
Change-Id: I3ae72befa008bfb37bac882de0986c5bcf9de079
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5425460
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Previously, Crashpad would only capture iOS thread context memory regions by iterating the task_threads->thread_get_state's. For Mach
exception this worked as intended. However, for signal exceptions this
missed the registers from the actual signal context. This change
correctly captures these regions and stores them in the exception
snapshot.
Change-Id: I494e753a25c2687e61b5183ed0135f520ca8bf52
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5380505
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
After https://crrev.com/c/5375084, Chromium __libcpp_verbose_abort is
handled differently for official non-dcheck builds. This change fixes
the test expectation for release non-official builds.
Bug: 330168249
Change-Id: Iceb6d327f9e93fd366cc07abe27eefd1adf06472
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5378380
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Arm's Pointer Authentication uses two keys for signing pointers, A-key
and B-key. Although by default Clang uses the A-key if PAC support is
enabled at compile time, this behaviour might be overridden via compiler
command line.
This CL fixes the check for the B-key being enabled. The key that shall
be used for Pointer Authentication is denoted by bits 0 (A-key) or
1 (B-key) of __ARM_FEATURE_PAC_DEFAULT. Hence, the previous way of
checking by using bits 0 and 2 does not correctly identify the B-key.
Bug: 40608466
Change-Id: Ib2f226baa12a7145fa0b6e486e49d36e6b0a3cd7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5341090
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
This CL make the iterators implemented by AnnotationList compliant to
the requirements imposed by the C++ standard on input iterators.
Change-Id: I263c94a97f5bcd7edd5ef4d8b65fa28b11876974
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5093147
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
There appears to be a change in dyld in macOS 14.3 that iOS 17
accounts for, but older simulators do not. This causes the main
binary to be listed twice when iterating modules, breaking some
tests.
Bug: crbug.com/328282286
Change-Id: I71909fbc13bee6de23b10ffd92a791067f8ea909
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5353754
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Chrome on ChromeOS is starting to run into problems where there are more
than 200 annotations, primarily because we use a lot of command-line
switches (40 or more) and commandline-enabled-features as well, each of
which takes up an annotation. It's still rare (100s a day) but will
probably become worse over time as more CrashKey uses are added.
Increase kMaxNumberOfAnnotations to 400.
BUG=296821415
Change-Id: Iba7049014ee3c5ae9c45c4022600eaba50acd403
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5354336
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ian Barkley-Yeung <iby@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This adds argv[0] for PLOG(FATAL) calls following a failed posix_spawn
or execve call to make logs more useful.
Bug: chromium:324982367
Change-Id: I179928ec9f791ce5b365b3444aa3bb667f4ec4b3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5315332
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
If building for chromium, honor the ios_is_app_extension gn variable
that is set per toolchain. When it is defined, the code is built for
an application extension (i.e. -fapplication-extension is passed to
the compiler).
Use CRASHPAD_IS_IOS_APP_EXTENSION build guard to not compile code
that use unavailable extension when ios_is_app_extension is set. If
the variable is not set, then check at runtime whether the API can
be used or not (if the crashpad client uses the same toolchain for
the main application and its application extensions).
This is required to pass -fapplication-extension to the compiler when
building application extensions (which allow catching API that is not
available to application extensions).
Bug: 40120082
Change-Id: I28d545fcfd0f8662430c40ff202b79b0c2b2ff8b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5286216
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
This change adds a method to update a CrashpadInfo stream.
As part of this change, AddUserDataMinidumpStream() now returns a handle
to the added stream. This handle can be passed to
UpdateUserDataMinidumpStream() if a new version of the stream needs to
be attached to the crash report.
This method is needed for e.g., allowing Chrome's System Profile to
update, as it contains some data that takes a while to collect.
Bug: crashpad:474
Change-Id: I19e935a6904d8843215582e5606b189479ee338b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5260024
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
The change in macOS 14's dyld to insert new modules in the front of
`dyld_all_image_infos` means that if the any images are loaded
during an exception while iterating the modules list, the primary
executable will be missed. Instead, read the modules in reverse
order.
Change-Id: I49f6468173f18ef4bd0f326c84e4b48cfc696cd3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5249275
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This assumption is non-portable and prevents Chromium from using
bounded iterators in libc++.
Bug: chromium: 1519908
Change-Id: Iafe6639ef3bc896d6fa4fb3ceb7ac0b546363017
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5237292
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
It's expected that iOS intermediate dumps can be written with
missing information, but it's better to try and report as much as
possible rather than drop the incomplete minidump.
Bug: b/284959148
Change-Id: I04110b576a4ee552814234d559c9ba85db0382f0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4582167
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This will trigger dead-code warnings in chromium once LOG(FATAL) is
understood as [[noreturn]], which needs to be fixed in crashpad first.
Bug: 1409729
Change-Id: I75cb4d93e648ca9804f1299345e52bb3e2834cd9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5193351
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
This CL introduces a new crash key 'crashpad_uptime_ns' that records the
number of nanoseconds between when Crashpad was initialized and when a
snapshot is generated.
Crashpad minidumps record the MDRawMiscInfo process_create_time using a
sysctl(KERN_PROC).kp_proc.p_starttime. This time is used to display the
'uptime' of a process. However, iOS 15 and later has a feature that
'prewarms' the app to reduce the amount of time the user waits before
the app is usable. This mean crashes that may happen immediately on
startup would appear to happen minutes or hours after process creation
time.
While initial implementations of prewarming would include some parts of
main, since iOS16 prewarming is complete before main, and therefore
before Crashpad is typically initialized.
Bug: crashpad:472
Change-Id: Iff960e37ae40121bd5927d319a2767d1cafce846
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5171091
Reviewed-by: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
This will be used by base/logging.h in chromium to make sure that
LOG(FATAL) variants never return and are properly understood as
[[noreturn]] by the compiler.
Once that's landed in chromium it'll be up/downstreamed into
mini_chromium as well.
Bug: chromium:1409729
Change-Id: I75340643fe075475f997bbc45250fa10df63c9fa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5185996
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
The real Chromium base/bit_cast.h is in the base namespace.
mini_chromium's version was just changed to be in the base namespace
as well. Roll to the latest mini_chromium and scope all calls to
bit_cast.
Bug: chromium:1506769
Change-Id: I7b25ee512f67694ef6ed3d0250e4f6a6db151eb3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5116880
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
bit_cast should never be used on pointers, as it doesn't avoid UB and
can lose qualifiers.
Fortunately, the only use of bit_cast on a pointer was to cast
nullptr into a function pointer, and because nullptr will implicitly
behave as any kind of pointer, that cast isn't needed.
Bug: none
Change-Id: I3ad79b36b7fb5ab53d4b4b6dfc82dea883ec8b53
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5106728
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
The implementation details of flags can change; fixing this proactively
makes it easier to roll googletest in chromium.
Bug: chromium:1409870
Change-Id: Ib27a922a5b3147386a36f98b42e60950e2215190
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5081703
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This CL implements a const iterator to allow for iteration over a const
AnnotationList. This way, the annotation list can passed as a const
reference in search only situations.
Change-Id: I53bd7871f3d914e7e7e627b6b464aa7fa79597f4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4984053
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Andre Kempe <andre.kempe@arm.com>
memcpy and memchr on NULL, 0 is UB due to a C language bug. Instead, use
the C++ functions, which do not have this bug.
Bug: chromium:1394755
Change-Id: I82023aa038c53905f9867c635b26f3b26d9994f5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4987148
Commit-Queue: David Benjamin <davidben@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
These are slightly frustrating. First, when a struct is packed, some of
its fields may be underaligned. This is fine for direct access
(foo.bar), but if one takes the address if the field, this creates an
unaligned pointer. Dereferencing that pointer is then UB. (I'm not sure
if creating that pointer is UB.)
Crashpad seemingly doesn't do this, but it uses EXPECT_EQ from GTest.
EXPECT_EQ seems to internally take pointers to its arguments. I'm
guessing it binds them by const reference. This then trips UBSan. To
avoid this, we can copy the value into a temporary before passing to
EXPECT_EQ.
Second, the test to divide by 0 to trigger SIGFPE is undefined behavior.
The compiler is not actually obligated to trip SIGFPE. UBSan prints one
of its errors instead. Instead, since this file is only built on POSIX
anyway, use GCC inline assembly to do the division. That one is
well-defined.
Finally, casting a string to uint32_t* is undefined both by alignment
and by strict aliasing (although Chromium doesn't enable the latter).
Instead, type-punning should be done with memcpy.
Bug: chromium:1394755
Change-Id: I79108773a04ac26f5189e7b88a0acbf62eb4401d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4985905
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: David Benjamin <davidben@chromium.org>
This reverts commit e17518a9e879f63b578db6c184c6bb17f1b13a06.
Reason for revert:
When trying to roll Crashpad into Chromium, all the new tests in
this CL fail; https://crrev.com/c/4984643?checksRunsSelected=win-rel&tab=checks
Original change's description:
> Add an option to start a Windows client with global hooks disabled.
>
> Change-Id: I645d6136788ca4ccebfc73005c8c2455dc4b2cee
> Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4949671
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Commit-Queue: Rich Mckeever <mckeever@google.com>
Change-Id: I3a41238cf0960899fac19d1e6d0ed0e527dfe13f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4985124
Reviewed-by: Mark Mentovai <mark@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Avi Drissman <avi@chromium.org>
Fixes a pending issue when we eventually move to C++20.
Original author: Dean Sturtevant
Change-Id: I7bb0648c73df6b6a28a3a4debdb4524d3cd27b38
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4979733
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Eric Astor <epastor@google.com>