988 Commits

Author SHA1 Message Date
Mark Mentovai
3b0a429371 Fix #includes
- Where std::nullptr_t is used (in namespace std), #include <cstddef>,
   even if it appears alongside <stddef.h> because types like intptr_t
   are used (in the root namespace).
 - Where math library functions are used, #include <cmath> to get and
   use the versions of functions in namespace std which are overloaded
   by argument type, such as std::isinf and std::isnan.

third_party is excluded.

Change-Id: Ic9c143f407e5a9c5cff4098cf566ba5caf4bf6d8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/6021439
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2024-11-14 17:06:54 +00:00
Peter Boström
70ccb76751 Accept longer Settings::Data structs
This attempts to be somewhat forward-compatible with upcoming additions
to the Data struct, most importantly to not lose the client ID if we
ever need to downgrade / read data from a future crashpad version.

Bug: 42310127
Change-Id: Ic3914fdd8460f4f41e5bb523d5c52361767880dd
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5915193
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Jesse McKenna <jessemckenna@google.com>
Commit-Queue: Peter Boström <pbos@chromium.org>
2024-10-22 02:23:41 +00:00
Jinyoung
1f24e58fd6 Make the network use proxy settings by default for Windows
Bug: chromium:369900059
Change-Id: I0b39a72938b3dc591ab8b4894a7a23a3deb4604d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5920056
Commit-Queue: Jinyoung Hur <hur.ims@navercorp.com>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2024-10-11 04:28:32 +00:00
Peter Kasting
f9fa2d112b [reland] Don't redefine macros from base/compiler_specific.h.
`DISABLE_CFI_ICALL` is already defined in that header; use it.

This is both simpler and less likely to trigger macro redefinition
errors.

This was previously landed in crrev.com/c/5805458, but reverted due to
crbug.com/362787700.

Bug: chromium:362787700
Change-Id: I1fc8d9dc0b099c67ea7d774034b7691691ff2a50
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5825328
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2024-08-28 22:57:49 +00:00
Mark Mentovai
50faaf111e Revert "Don't redefine macros from base/compiler_specific.h."
This reverts commit 458bdec9852280f091a72f9d90eb75f04d0af05f.

Reason for revert: Crashpad roll into Chrommium failed.

https://chromium-review.googlesource.com/c/5805903
https://ci.chromium.org/ui/p/chromium/builders/try/android-x64-rel/171929/
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8738938901079891665/+/u/compile__with_patch_/stdout

While linking libcrashpad_handler_trampoline.so:

```
ld.lld: error: undefined symbol: std::__Cr::__libcpp_verbose_abort(char const*, ...)
>>> referenced by ascii.cc
>>>               obj/third_party/abseil-cpp/absl/strings/strings/ascii.o:(std::__Cr::__throw_out_of_range(char const*))
>>> referenced by lightweight_quarantine.cc
>>>               allocator_core/lightweight_quarantine.o:(partition_alloc::internal::LightweightQuarantineBranch::~LightweightQuarantineBranch()) in archive obj/base/allocator/partition_allocator/src/partition_alloc/liballocator_core.a
>>> referenced by lightweight_quarantine.cc
>>>               allocator_core/lightweight_quarantine.o:(partition_alloc::internal::LightweightQuarantineBranch::Purge()) in archive obj/base/allocator/partition_allocator/src/partition_alloc/liballocator_core.a
>>> referenced 1 more times
[…]
ld.lld: error: undefined symbol: std::get_new_handler()
[…]
ld.lld: error: undefined symbol: _Unwind_Backtrace
[…]
ld.lld: error: undefined symbol: _Unwind_GetIP
[…]
ld.lld: error: undefined symbol: __cxa_guard_acquire
[…]
ld.lld: error: undefined symbol: __cxa_guard_release
[…]
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

Original change's description:
> Don't redefine macros from base/compiler_specific.h.
>
> `DISABLE_CFI_ICALL` is already defined in that header; use it.
>
> This is both simpler and less likely to trigger macro redefinition
> errors.
>
> Bug: none
> Change-Id: I3ecfe9b6dc4ac42c6a69b3fd9c6d2c68fe8e62a2
> Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5805458
> Reviewed-by: Mark Mentovai <mark@chromium.org>

Bug: none
Change-Id: Ie225e03e07ab3d0a00933217b377cee14fcdb8b7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5806223
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2024-08-22 16:33:50 +00:00
Peter Kasting
458bdec985 Don't redefine macros from base/compiler_specific.h.
`DISABLE_CFI_ICALL` is already defined in that header; use it.

This is both simpler and less likely to trigger macro redefinition
errors.

Bug: none
Change-Id: I3ecfe9b6dc4ac42c6a69b3fd9c6d2c68fe8e62a2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5805458
Reviewed-by: Mark Mentovai <mark@chromium.org>
2024-08-22 02:47:50 +00:00
Peter Boström
6265674c98 Migrate to NOTREACHED()
This was tested locally by adding "-Wunreachable-code-aggressive" after
making NOTREACHED() [[noreturn]] in mini_chromium and then getting that
to compile.

Bug: chromium:40580068
Change-Id: I7ec1c72be1d73436d128660a621e9060eaebaee8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5780891
Reviewed-by: Mark Mentovai <mark@chromium.org>
2024-08-14 03:11:45 +00:00
Peter Boström
cc54fcc7f5 Fix trailing NOTREACHED_NORETURN()
This alias is not present in mini_chromium and disappearing from
chromium.

Bug: chromium:40580068
Change-Id: Ib6218d96df3bb8b2fe46af08ac51d6362c7db64e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5783604
Reviewed-by: Mark Mentovai <mark@chromium.org>
2024-08-14 01:57:47 +00:00
Mark Mentovai
d380daf704 Update cpp-httplib to 6a848b1a1643
Most significantly, this includes:

6a848b1a1643 Require a minimum of TLS 1.2 (#1889)

Although Crashpad only uses cpp-httplib in tests, there’s no reason to
taunt fate with this tempting juicy morsel. TLS 1.1 is deprecated
(https://datatracker.ietf.org/doc/html/rfc8996, 2021-03).

This includes a change to util/net/http_transport_test_server.cc to
ensure that the test server, which runs in a child process, continues to
return the full multipart request body as it had in the past. Since
cpp-httplib 7e420aeed361 introduced multipart handling, the raw
multipart wrapper no longer appears in Request::body, but is instead
made available at Request::files. With this change, the test server will
reconstitute the original request body to match the test’s expectations.
Note that this isn’t the only way to serialize the request to be
conveyed back to the test, but it’s the most expedient because it’s what
the test already expects, and because the existing framing already takes
the form of the raw HTTP request.

Change-Id: Ia4adaedff0873976f7cc5be138d78f931165fe4e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5753782
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2024-07-31 17:46:48 +00:00
Daniel Cheng
aef7de4e93 [MSan] "Fix" use-after-dtor in InitializationState.InitializationState
Since the test is specifically trying to exercise UB by testing the
state of an object it is already destroyed, unpoison the memory to
suppress MSan errors.

Bug: 40222690
Change-Id: I840e944f5e8b39668ac05d8d641fdd5f2e3db5ac
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5716150
Reviewed-by: Mark Mentovai <mark@chromium.org>
2024-07-17 17:08:24 +00:00
Justin Cohen
0bebda66a8 ios: Remove duplicate implementations of ReadStringSysctlByName
Bug: crashpad: 480
Change-Id: Ie37c557d2170f6d96968ec4922ec52bfc6ad8136
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5580854
Reviewed-by: Mark Mentovai <mark@chromium.org>
2024-06-04 18:25:16 +00:00
Peter Boström
6af42bc0b2 Use NOTREACHED_IN_MIGRATION()
This was generated by replacing "  NOTREACHED()" with
"  NOTREACHED_IN_MIGRATION()" and running git cl format.

This prepares for making NOTREACHED() [[noreturn]] alongside
NotReachedIsFatal migration of existing inventory.

Bug: chromium:40580068
Change-Id: Idb68e2fc8adba180350b0595fd494cf0f206bded
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5548246
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
2024-05-17 16:30:52 +00:00
Ben Hamilton
d588c50b16 [ScopedSpinGuard] Use std::atomic::compare_exchange_strong() for spinlock
Previously, ScopedSpinGuard used std::atomic::compare_exchange_weak()
in a loop to implement a spinlock. After looping for the specified
number of nanoseconds, it would give up and return an error.

A few bugs have come in on ARM platforms (https://crbug.com/340980960,
http://b/296082201) which indicate that this can fail even in
single-threaded cases where nothing else has the spinlock.

From https://cbloomrants.blogspot.com/2011/07/07-14-11-compareexchangestrong-vs.html :

> compare_exchange_weak exists for LL-SC (load linked/store
> conditional) type architectures (Power, ARM, basically everything
> except x86), because on them compare_exchange_strong must be
> implemented as a loop, while compare_exchange_weak can be
> non-looping.

and:

https://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange#Notes

> compare_exchange_weak is allowed to fail spuriously, that is, acts
> as if *this != expected even if they are equal. When a
> compare-and-exchange is in a loop, compare_exchange_weak will yield
> better performance on some platforms.
>
> When compare_exchange_weak would require a loop and
> compare_exchange_strong would not, compare_exchange_strong is
> preferable [...]

My conclusion is that this logic needs to use
`compare_exchange_strong` to avoid spurious failures on ARM in the
common case when there's no other thread holding the spinlock.

Change-Id: I2a08031db6b219d7d14a5cd02b3634985f81ab06

Bug: b:340980960
Change-Id: I2a08031db6b219d7d14a5cd02b3634985f81ab06
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5545257
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
2024-05-16 22:16:59 +00:00
Arthur Wang
981d4189aa Replace std::unique_ptr<T> with HeapArray
Bug: crashpad: 326459659,326458942,326459376,326459390,326459417,326458979,326459333,326459016,326458338,326458738,326459156,326459512,326458694
Change-Id: I04724530cbef50a8d3c18f306d16c0bbf3b0815b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5512394
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Arthur Wang <wuwang@chromium.org>
2024-05-09 22:16:58 +00:00
danakj
5c09c9a701 Include build_config.h before checking COMPILER_MSVC
This is caught by chromium presubmit when rolling crashpad.

R=mark@chromium.org

Change-Id: Ida9ff07e7b2bd27808c092afbc5a1345fa29a4f3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5515300
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
2024-05-06 14:47:42 +00:00
danakj
84c87739e8 Use the span version of RandBytes
Some unique_ptr<T[]> are also changed to HeapArray in order to
facilitate the change.

Bug: chromuim: 40284755
Change-Id: I30b9d55ff81f23c63ad4958786740f67ee612024
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5512569
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
2024-05-06 14:12:00 +00:00
Andrew Williams
bff9873242 Make NTSTATUS_LOG less likely to change ::GetLastError() value
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>
2024-05-03 23:13:34 +00:00
Andrew Williams
da189353b6 Replace std::is_pod usage
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>
2024-05-03 21:22:37 +00:00
Arthur Wang
76badd4c20 Replace std::unique_ptr<T[]> with HeapArray in process_info.cc and
process_info_test.cc

Bug: crashpad: 326459035,326458915,326459055
Change-Id: Ifb91297b6097aa81a9d5c883b2c284e9fdd512a8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5463361
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Arthur Wang <wuwang@chromium.org>
2024-05-02 15:53:17 +00:00
danakj
7e0af1d4d4 Use byte conversions over the byte swap functions
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>
2024-04-11 17:31:35 +00:00
André Kempe
6bf5e1b5c5 Fix invalid check for valid key of Pointer Authentication
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>
2024-03-15 14:10:46 +00:00
Peter Boström
bc4fd34fe2 Log argv[0] for failing spawns
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>
2024-02-22 19:28:55 +00:00
Sylvain Defresne
5075fb617a Honor ios_is_app_extension chromium build flag
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>
2024-02-12 15:43:24 +00:00
danakj
a02e4935bd Avoid assuming string_view iterators are char*
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>
2024-01-26 14:03:07 +00:00
Justin Cohen
30b2f4ba38 ios: Add crashpad_uptime_ns crash key to iOS reports.
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>
2024-01-11 16:42:54 +00:00
Peter Boström
98d0d86e76 Add [[noreturn]] version of NtstatusLogMessage
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>
2024-01-11 16:15:20 +00:00
David Fang
2905784a7d [build] Re-enable action tracing
Avoid unconditionally running mig in incremental builds,
and causing un-necessary re-build of downstream targets.

Bug: b/42147841
Bug: b/42084680
Change-Id: I961189870aec8f0b1a1ced22105730218664e109
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5171755
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: David Fang <fangism@google.com>
2024-01-06 04:24:21 +00:00
Avi Drissman
9f896f2581 Qualify bit_cast with base::
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>
2023-12-12 22:52:47 +00:00
Ben Hamilton
337b4f7971 [mac] mach_absolute_time() -> clock_gettime_nsec_np(CLOCK_UPTIME_RAW)
https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time

> Prefer to use the equivalent clock_gettime_nsec_np(CLOCK_UPTIME_RAW) in nanoseconds.

The two are equivalent:

c5a3293354/gen/clock_gettime.c (L118)

Change-Id: I1c7a08d821d1840b74fc5eaa0e9ceca2ade5bbfc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5085307
Commit-Queue: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-12-12 18:08:21 +00:00
Lei Zhang
5613499bbd Replace base::WStringPiece with std::string_view
Bug: chromium:691162
Change-Id: I2d34bcfd3b97d59d1811183d62b893b875b08bb4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5010942
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2023-11-07 21:04:05 +00:00
Lei Zhang
1675ce7c58 Add missing base/check.h includes
Do not rely on base/logging.h to provide it.

Change-Id: I8b7d733bcf66abe9b46eabd3703b7ed549d02db7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5007844
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-11-06 22:00:17 +00:00
David Benjamin
41f6ad560f Fix crashpad tests under UBSan
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>
2023-10-30 19:31:22 +00:00
Avi Drissman
188ad79298 Roll crashpad/third_party/mini_chromium/mini_chromium/ 707c87bd2..98bbdbe49 (1 commit) + changes
707c87bd25..98bbdbe49f

$ git log 707c87bd2..98bbdbe49 --date=short --no-merges --format='%ad %ae %s'
2023-10-27 avi Update ScopedTypeRef

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

---

In addition, change implicit unwrapping of ScopedCFTypeRef to be
explicit.

Bug: chromium:1495438, chromium:1495439
Change-Id: I47dd12f94f71caaad74cf23be9da9d03a59772db
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4984741
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-10-27 16:15:49 +00:00
Eric Astor
59fc31ce00 Update mini_chromium & use its new support for wide streaming in file_path
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>
2023-10-26 22:15:17 +00:00
Lei Zhang
c63c073d27 Do IWYU for check_op.h
Include check_op.h directly, instead of relying on the transitive
include from logging.h. This transitive include does not exist in
Chromium's //base.

Change-Id: I15962a9cdc26ac206032157b8d2659cf263ad695
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4950200
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2023-10-18 20:01:37 +00:00
Peter Kasting
aef75040fd Use format macros for int64_t instead of hardcoding the format.
Bug: 1371963
Change-Id: I7fa4557472684cdd2b8e0cc977230941f26f1eaa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4943901
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
2023-10-16 23:52:56 +00:00
Alex Gough
ac0c27a923 Deregister vectored exception handler on client destruction
Some users of crashpad load and unload the dll that hosts
crashpad code. crashpad registers a vectored exception handler
to help collect heap corruption crashes. If the dll is
unloaded this handler might still be called.

This CL adds a scoped handler for such registrations and
uses it on Windows crashpad client. To allow this to
be stored, RegisterHandler() on the client needs to move
onto the client object from being a helper function.

Bug: crashpad:462
Change-Id: I5d77c056e2a9a61ddcfa9d0186ab4bfd85a19bff
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4898263
Reviewed-by: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2023-09-28 17:24:39 +00:00
Avi Drissman
a736f7d070 Roll mini_chromium putting /base/apple files into base:🍎:
Bug: chromium:1474628
Change-Id: Ief0efef22759b935045bf0216a313c2de8025403
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4799234
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
2023-08-21 20:35:28 +00:00
Avi Drissman
13e3accfe8 Roll mini_chromium, adjust to more files in base/apple
This rolls mini_chromium to the version that has more files in
base/apple, and adjusts the code to match.

Bug: chromium:1444927
Change-Id: I9642698c8c16151bd0aaca7b46745a59d6e5e6d3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4791121
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
2023-08-17 15:25:58 +00:00
Avi Drissman
6a9e2e6003 Adjust to movement of base/ files to base/apple
This CL rolls mini_chromium to pick up the move of a bunch of files
to base/apple, and makes changes to adjust.

Bug: chromium:1444927
Change-Id: Ib692e2a1628e2c0c8228795eaecdb7f35b1c09fa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4786387
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
2023-08-16 21:05:16 +00:00
Thomas Gales
343aa69084 Revert "[fuchsia][mac] Fix build errors"
This reverts commit ca6d64d0ae4905ad7033adab0a28273a0741ee5c.

Reason for revert: The changes did not actually fix the problem once combined with the latest changes from mini_chromium.

Original change's description:
> [fuchsia][mac] Fix build errors
>
> A recent CL [1] broke Fuchsia's Crashpad roller due to duplicate build
> argument declarations. This CL ensures that sysroot.gni is only imported once.
>
> [1] https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/4651973
>
> Fixed: fuchsia:131454
> Change-Id: Idcf6ac65cdffee2c9a9551559a8aab0063044428
> Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4743381
> Reviewed-by: Joshua Peraza <jperaza@chromium.org>
> Commit-Queue: Thomas Gales <tgales@google.com>

Change-Id: Id3dc42484fbd87e242756c8d2889d2e404370ac7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4753637
Commit-Queue: Thomas Gales <tgales@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2023-08-04 20:26:15 +00:00
Peter Kasting
419f995aab Ban [w]ctype.h: crashpad
Bug: chromium:1361094
Change-Id: Ia5dacb9038cd74b5d490282a8070fb4579ebe3ae
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4750179
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
2023-08-04 16:50:05 +00:00
Avi Drissman
617429d358 Remove ARC boilerplate in Crashpad
ARC is now enabled by default, so there’s no need to enforce it
against files being put into non-ARC targets.

Bug: chromium:1468376
Change-Id: I58bbb4d1736293a6e9977954ce932dcfe2bafa54
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4750419
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2023-08-03 20:21:42 +00:00
Thomas Gales
ca6d64d0ae [fuchsia][mac] Fix build errors
A recent CL [1] broke Fuchsia's Crashpad roller due to duplicate build
argument declarations. This CL ensures that sysroot.gni is only imported once.

[1] https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/4651973

Fixed: fuchsia:131454
Change-Id: Idcf6ac65cdffee2c9a9551559a8aab0063044428
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4743381
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Thomas Gales <tgales@google.com>
2023-08-02 23:02:59 +00:00
Thomas Gales
8dcf2b216f [fuchsia] Don't build CaptureContext
CaptureContext isn't actually used on Fuchsia and there is a desire to
remove `ucontext_t` from Fuchsia as it isn't a real concept on Fuchsia
and was only added as a placeholder. Moreover, `ucontext_t` won't ever
be added to Fuchsia for RISC-V.

Bug: fuchsia:123052
Fixed: fuchsia:131112
Fixed: fuchsia:127655
Tested: `fx test crashpad` on core.x64 emulator
Tested: `fx test crashpad` on ARM64 device
Tested: `fx shell crasher` @ 16b19a9891978487 on ARM64 device, ran
through Breakpad stackwalker locally as well
Tested: `fx build crashpad_tests` for minimal.riscv64
Change-Id: I4695054426df78a9deff8c9ea9c478b5bf9701b1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4717085
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Thomas Gales <tgales@google.com>
2023-07-31 20:03:40 +00:00
Avi Drissman
00ce1f9f8f Disable PtraceBroker.SameBitness
Bug: chromium:1459865
Change-Id: I28d5caa739c5b59f4af1f062616443aa16fadfa1
Fixed: chromium:1459862
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4663174
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2023-07-05 15:47:28 +00:00
Avi Drissman
9e37dc46b6 Convert Crashpad to use ARC
See
https://chromium.googlesource.com/chromium/src/+/main/docs/mac/arc.md
for information about this conversion.

Bug: chromium:1280726
Change-Id: I9ed10e9a255eb6b13035b05bcc587c4b6cb7b78e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4651106
Reviewed-by: Mark Mentovai <mmentovai@google.com>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-06-30 15:55:24 +00:00
Thomas Gales
2cf938a41d [riscv][fuchsia] Add RISC-V Fuchsia support
Only RV64GC is supported.

RISC-V Fuchsia is not able to serve packages yet so unit testing is not
possible.

Bug: fuchsia:127655

Tested: `crasher` with crashpad added to crashsvc, ran minidump through
Breakpad stackwalker

Change-Id: I1b6d79128759281aee348e333ea15434ab397001
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4602412
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2023-06-12 21:13:43 +00:00
Thomas Gales
4f5dd67229 [riscv] Add RISC-V Linux support
Only RV64GC is supported.

Bug: fuchsia:127655

Tested: `python build/run_tests.py` on RISC-V emulator
Tested: Created minidump via self-induced crash on RISC-V emulator,
ran through Breakpad stackwalker

Change-Id: I713797cd623b0a758269048e01696cbce502ca6c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4581050
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2023-06-12 21:13:24 +00:00
Eran Rom
788b72f922 Remove Mac OS X Server support
Mac OS X Server has been discontinued as a separate operating system
flavor since 10.6. Current minimal requirements for both Crashpad and
Chromium are above that.

Change-Id: Ia9063be2e55a48e45d9f9974ac2e51bac004f37d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4584570
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-06-02 19:12:29 +00:00