481 Commits

Author SHA1 Message Date
Peter Boström
6c57c083e6 Fix -Wsign-compare in CrashReportDatabaseTest
Bug: crashpad:42310127
Change-Id: I8a060afd6d976379064c4177a40b337942252087
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5951643
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
2024-10-22 06:14:14 +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
Nico Weber
032bcc92fb Mark CrashWithoutDumping() as [[noreturn]]
No behavior change.

Bug: none
Change-Id: Ie838df830221a09d5401c6c73c8c889ea714940e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5905738
Reviewed-by: Peter Boström <pbos@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
2024-10-04 04:08:15 +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
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
Justin Cohen
371083179b ios: Use correct address when storing register memory.
The memory region data saved in the intermediate dump is an address
offset by 128 bytes. However, the MemorySnapshot generated was using the
original address and not the offset address.  The same data is being
captured in the minidump.

Change-Id: Ia34912c035319e79cf446a130e662084f4ab51ea
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5529059
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
2024-05-09 18:56:10 +00:00
Ben Hamilton
8df174c64c [ios] Fix TSAN issue and Mach port leak in CrashpadClient
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>
2024-04-11 17:00:05 +00:00
Justin Cohen
1cea0473a5 ios: Capture signal exception context memory regions correctly.
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>
2024-03-21 20:10:05 +00:00
André Kempe
dea283a7eb Make AnnotationList's iterator compliant to input iterator
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>
2024-03-15 14:08:58 +00:00
Justin Cohen
c4d4a4d83e ios: Disable annotations tests on older simulators on macOS 14.3
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>
2024-03-08 22:44:08 +00:00
Jesse McKenna
940e8a3445 Fix leaky CrashpadInfo test
CrashpadInfo::AddUserDataMinidumpStream() and
UpdateUserDataMinidumpStream() allocate memory for the newly added
streams. This change makes the CrashpadInfo test free that allocated
memory to prevent memory leaks from these tests.

This is intended to fix the ASAN failures seen on crrev.com/c/5285881:
https://ci.chromium.org/ui/p/chromium/builders/try/linux_chromium_asan_rel_ng/1839072/overview

Bug: crashpad:474
Change-Id: I6e030291594d22e316942a58805a177ce448053b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5292137
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
2024-02-13 18:34:48 +00:00
Jesse McKenna
c576bf35ea Add Update method to CrashpadInfo
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>
2024-02-09 21:32:29 +00:00
Justin Cohen
5d81482aea ios: Read dyld modules in reverse order.
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>
2024-02-01 22:08:46 +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
Ben Hamilton
3a20cc2447 [ios] Add arm64e support to in_process_intermediate_dump_handler
Change-Id: Ifc373d313db71872cc0fd7706da2bdc07cf4ba1b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5126940
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
2023-12-18 18:34:11 +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
Avi Drissman
7049d966b5 Fix improper use of bit_cast
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>
2023-12-08 22:15:17 +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
Justin Cohen
3ba2403a73 ios: Fix leak in iOS NSException preprocessor.
Call __cxa_free_exception after __cxa_allocate_exception usage.

Change-Id: I0cd5043b945652e6ac28c3bf79486c071d3aa09e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4990028
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-10-31 17:06:02 +00:00
André Kempe
c39206f699 Provide a way to iterate over a const AnnotationList
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>
2023-10-31 08:24:31 +00:00
David Benjamin
c5e2b0313c Fix UB when saving an StringAnnotation
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>
2023-10-30 19:33:13 +00:00
Avi Drissman
4a93d7f4c4 Revert "Add an option to start a Windows client with global hooks disabled."
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>
2023-10-27 20:45:09 +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
Rich Mckeever
e17518a9e8 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>
2023-10-26 19:40:30 +00:00
Peter Kasting
376e8c0e69 Eliminate call to StringPrintf() with non-constexpr format string.
Bug: 1371963
Change-Id: Ic3cc2010e48c399de8d19b94c3b515b53e2d18a3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4953795
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-10-19 00:33:53 +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
Leonard Grey
63ec9482cf Windows: don't compile HandleHeapCorruption on ASAN
f145b54e8378c8e2bd1fbb427684ca9b4c54ea9c put the only reference to this
in a non-ASAN block, so we're hitting an unused function warning rolling
into Chromium

Bug: crashpad:464
Change-Id: I225debd48a255aa5214e02a6821dcd72c618f141
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4939552
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
2023-10-16 15:10:06 +00:00
Rich Mckeever
f145b54e83 Stop registering Windows VEH in ASAN builds.
ASAN injects a bad de-reference in HandleHeapCorruption() that causes it to be recursively invoked.

Bug: crashpad:464
Change-Id: I5e8db5555462166b963e0e43c6eb8ac0b327219e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4935953
Reviewed-by: Alex Gough <ajgo@chromium.org>
Commit-Queue: Rich Mckeever <mckeever@google.com>
2023-10-13 14:39:58 +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
Keishi Hattori
a7cfe95351 Reland "Add SetLastChanceExceptionHandler to implement permissive MTE mode"
This is a reland of commit b1e66e322ddd07f4640ee8bad93397a0511cd313

Original change's description:
> Add SetLastChanceExceptionHandler to implement permissive MTE mode
>
> SetLastChanceExceptionHandler sets a callback to be called after a
> crash has been reported. Returning true from this callback will
> not reraise the signal so the execution can continue. This will be
> used to implement permissive MTE mode, which will continue execution
> after a MTE crash.
>
> Bug: chromium:1467915
> Change-Id: I93a28ceea921fe977805482cf47c07643ca6133c
> Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4707688
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Commit-Queue: Keishi Hattori <keishi@chromium.org>

Bug: chromium:1467915
Change-Id: Ibdc18084deb08bccf3c74f688b7d48ff24fe81f9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4756235
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Keishi Hattori <keishi@chromium.org>
2023-09-05 12:40:07 +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
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
Keishi Hattori
ce7f0f1de9 Revert "Add SetLastChanceExceptionHandler to implement permissive MTE mode"
This reverts commit b1e66e322ddd07f4640ee8bad93397a0511cd313.

Reason for revert: test was flaky on Android bot

Original change's description:
> Add SetLastChanceExceptionHandler to implement permissive MTE mode
>
> SetLastChanceExceptionHandler sets a callback to be called after a
> crash has been reported. Returning true from this callback will
> not reraise the signal so the execution can continue. This will be
> used to implement permissive MTE mode, which will continue execution
> after a MTE crash.
>
> Bug: chromium:1467915
> Change-Id: I93a28ceea921fe977805482cf47c07643ca6133c
> Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4707688
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Commit-Queue: Keishi Hattori <keishi@chromium.org>

Bug: chromium:1467915
Change-Id: Id815a780b576088974101117a4587adec64cfe8c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4750459
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-08-03 19:12:36 +00:00
Keishi Hattori
b1e66e322d Add SetLastChanceExceptionHandler to implement permissive MTE mode
SetLastChanceExceptionHandler sets a callback to be called after a
crash has been reported. Returning true from this callback will
not reraise the signal so the execution can continue. This will be
used to implement permissive MTE mode, which will continue execution
after a MTE crash.

Bug: chromium:1467915
Change-Id: I93a28ceea921fe977805482cf47c07643ca6133c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4707688
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Keishi Hattori <keishi@chromium.org>
2023-08-03 16:00:18 +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
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
Alex Gough
a5e179663a Catch heap corruption failures on Windows
Windows claims that heap corruption crashes are passed
to Windows Error Reporting but they are not, they are
swallowed and the process is simply terminated. WerFault.exe
does not run.

We can however intercept these crashes using a vectored
exception handler which forwards STATUS_HEAP_CORRUPTION
to the normal crash handler.

Adds an end-to-end test.

Bug: 2515
Change-Id: I2e1361dacef6fd03ea0f00327fee0b05a0c4899e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4637533
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2023-06-23 23:06:52 +00:00
Ho Cheung
07827d9807 Remove base/cxx17_backports.h from the code in third_patry/crashpad
Remove the reference to `base/cxx17_backports.h` from the code.

Bug: chromium:1373621
Change-Id: I84dd5fc1b069b168e4558316344c1f1c5377a68b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4471860
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-04-25 20:33:34 +00:00
Zequan Wu
3a6bc8c527 [tests] Disable clang optimization on the infinite recursion function.
In the recent llvm upstream change, https://reviews.llvm.org/D148269,
clang becomes smarter and will remove the infinite recursion function.
Use the clang attribute __attribute__((optnone)) to disable optimization
for it.

Bug: chromium:1435016
Change-Id: I74e823bf64d0b03d81c0bda7a8338e2fa67033aa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4456156
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Zequan Wu <zequanwu@google.com>
2023-04-21 17:58:33 +00:00
Justin Cohen
3cd7b5bf7f ios: Fix crash in ObjcExceptionPreprocessor.
ObjcExceptionPreprocessor is a 'reasonable effort' attempt to catch an
NSException minidump at time the exception is thrown as opposed to when the application terminates due to the exception. If multiple
exceptions are thrown at the same time, Crashpad should correctly
report the final uncaught exception, but the minidump may not
represent the full `caught-at-thrown` minidump.

 - Don't assume ObjcExceptionPreprocessor throws an NSException.
 - Don't retain/release the exception. Instead of calling isEqual,
   just use a simple pointer comparison.
 - Make last_exception atomic.

Bug: crashpad: 445, 446
Change-Id: I9f2f2041e96aa9818c63937025e507487ae9d03d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4317110
Reviewed-by: Ben Hamilton <benhamilton@google.com>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2023-03-15 00:49:36 +00:00
David Benjamin
90bba04e22 Fix some accidental uses of argument-dependent lookup
StringToInt(string_piece) works because base::StringPiece is in
namespace base, but when it is switched to std::string_view, this won't
work anymore. Use the idiomatic spelling.

Bug: chromium:691162
Change-Id: Ic45e0d2729fa5fc7c3e7a56fe159957b1bdcdf94
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4298113
Commit-Queue: David Benjamin <davidben@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2023-02-28 22:02:28 +00:00
Justin
70e0f92153 Fix StringPiece compile issue in Chromium.
Change-Id: I5a29f690a4512252d0d5730492f7fd4cec16ffaa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4262547
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-02-16 20:19:10 +00:00
Ben Hamilton
485805c6fe Fix test that relied on NDEBUG always disabling DCHECK
The test BaseAnnotationShouldNotSupportSpinGuard assumed NDEBUG builds
always disabled DCHECK()s, but DCHECK_ALWAYS_ON overrides this.

This CL fixes the test for NDEDBUG + DCHECK_ALWAYS_ON builds by using
the DCHECK_IS_ON() macro to skip the test when DCHECKs are enabled.

Change-Id: I7b64729568c5d3139ca777e27462d81eba931834
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4255429
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
2023-02-15 20:42:52 +00:00
Ben Hamilton
c7d9c710f2 [ios] Support guarding concurrent reads and writes to Annotations
Since iOS reads Annotations in-process, this CL updates the iOS
intermediate dump handler to check each Annotation to see if it supports
guarding concurrent reads and writes using ScopedSpinGuard.

For any such Annotation, the in-process dump handler now tries (without
spinning) to obtain the ScopedSpinGuard for the Annotation before
reading its memory.

If the ScopedSpinGuard cannot immediately be obtained, the in-process
dump handler just skips writing the memory of the Annotation to the
intermediate dump. (I'd like to follow up and thread down a Params
object so we can experiment with adding an optional timeout to make
this more reliable.)

Change-Id: Ie6c9849fac94ab89b36364b07aea62326cabe552
Bug: crashpad:437
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4031730
Commit-Queue: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2023-02-01 19:27:26 +00:00
Ben Hamilton
212b8f6b8c [client] New RingBufferAnnotation
This CL integrates the new ScopedSpinGuard with the new
LengthDelimitedRingBuffer into a new class, RingBufferAnnotation.

RingBufferAnnotation is thread-safe both for reading and writing, and is
suitable for streaming logs, trace events, and other high-throughput
data streams.

I included a load test (ring_buffer_annotation_load_test) which launches
two threads which simultaneously write to and read from the
RingBufferAnnotation.

By default, reads and writes are serialized using ScopedSpinGuard, but
passing the flag "--disable_spin_guard" to the test disables the spin
guard on the reading side (which is expected to make the test fail).

Change-Id: Ic8e28866d085d57e778c4f86bcb7492ef0638ab9
Bug: crashpad:437
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4023619
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
2023-02-01 19:23:51 +00:00
Ben Hamilton
3215ed9086 [client] Optionally support ScopedSpinGuard in Annotation
This CL optionally integrates ScopedSpinGuard (an atomic boolean) with
crashpad::Annotation.

Subclasses of Annotation can choose to integrate ScopedSpinGuard into
their Set(...) methods to ensure reads and writes are serialized.

I didn't integrate this into StringAnnotation in this CL, but it'd be
pretty trivial to do in a follow-up.

Change-Id: I1c5b8982576b03f9780a57acb7627c9194f8f0ff
Bug: crashpad:437
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4022484
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2023-01-31 22:37:44 +00:00
Ben Hamilton
8071d3019e [client] Clean up types and code style in LengthDelimitedRingBuffer
This CL cleans up types and code style comments from post-submit code
review comments on https://crrev.com/c/4023618 .

I also added fixes for potential overflows in varint length decoding
and included new tests.

Bug: crashpad:437
Change-Id: I0a3585036028d81f42d0d36e87cce4264f4ed9ad
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4199705
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-01-30 21:18:59 +00:00
Justin Cohen
c11d49db88 Add a mask to MinidumpCrashpadInfo to indicate valid pointer addresses.
ARM64 supports storing pointer authentication codes in the upper bits of
a pointer. This mask can be used by LLDB to mimic ptrauth_strip and
strip the pointer authentication codes. To recover an address from
pointer with an authentication code, `AND` this mask with the pointer.

If the platform does not support pointer authentication, or the range of
valid addressees for a pointer was unaccessible, this field will be 0
and should be ignored.

Change-Id: Ie5cef90802dd1e892d456195ab8874223eac6a1b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2773358
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-01-30 18:27:02 +00:00
Ben Hamilton
1a7918b716 [client] New class LengthDelimitedRingBuffer
This CL implements LengthDelimitedRingBuffer, a general-purpose
ringbuffer suitable for use as a Crashpad Annotation.

This ringbuffer supports writing variably-sized data delimited by a Base
128 varint-encoded length separator.

LengthDelimitedRingBuffer is backed by a std::array, so it has a fixed
maximum size. It supports reading via RingBufferReader as well as
writing via RingBufferWriter.

Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4023618
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
2022-12-15 17:30:43 +00:00