238 Commits

Author SHA1 Message Date
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
Justin Cohen
ccd20652bc ios: Update exception test for Chromium release builds.
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>
2024-03-18 18:21:32 +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
Peter Boström
5183bef5f3 Remove should-be-dead code after PLOG(FATAL)
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>
2024-01-12 21:41:10 +00:00
Daniel Cheng
5fc60aeb3b Use googletest flag macros to access googletest flags.
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>
2023-12-04 16:10:52 +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
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
Sylvain Defresne
7c89d500cd [ios] Remove ios_use_shared_bundle_id_for_test_apps gn variable
The variable was to true in https://crrev.com/c/3308823 and is
never overridden. Remove it as it simplify the logic of the
test targets (and remove code duplication).

  This is a followup to https://crrev.com/c/4935576 which make
  the corresponding change in the Chromium repository.

Bug: 1250788
Change-Id: Ide05fa3bf4177b5761ef0ad5c6edf9baf181b28c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4943570
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2023-10-16 16:04:01 +00:00
Justin Cohen
b90db3e47f ios: Fix Chromium bundle id for xcuitest.
This is needed in Chromium for enabling iOS PartitionAlloc

Rolls mini_chromium to support overriding the BundleIdentifier.

Bug: 1489308
Change-Id: I314958182f35edba3300e545b2877d288b43ccb9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4911575
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2023-10-04 19:29:39 +00:00
Mike Frysinger
52c427a2e4 tests: stop using legacy gtest APIs
These are being removed from gtest, so stop using them.

Bug: chromium:1474588
Change-Id: I0d42da9f14dad5c5dc17d980146cb289d444dbda
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4803329
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
2023-08-22 23:14:23 +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
43d04a8661 Update comment for new file location
https://crrev.com/c/4781926 moves PA files to new locations. This
updates the filename reference.

Bug: chromium:1444927
Change-Id: I7947711055eb444ab5bc28d4e3c6ca2c39a17e04
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4784548
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-08-16 19:01:57 +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
Clayton McCray
dcba40ceea [inspect] Route InspectSink in crashpad
Bug: 93344
Change-Id: Id794e3c79983b4c2352842edfe73a81ad3958b6e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4676565
Commit-Queue: Clayton McCray <claytonmccray@google.com>
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Francois Rousseau <frousseau@google.com>
2023-07-11 17:00:36 +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
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
Justin Cohen
1fdbd3736c ios: More deflaking handler forbidden allocators.
- Stop overloading introspect (or implement this in the future)
- Store each overridden allocation zone and correctly direct calls to
  the requested zone.

Change-Id: I7294e476bb683149acc61419b095ec0e1098781b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4574037
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2023-05-31 01:13:35 +00:00
Justin Cohen
1103dfc65d ios: Add fallbacks to try_free_default and claimed_address in forbidden allocators.
This test only change should improve flake on iOS XCUITests. try_free_default can receive a pointer which doesn't belong to the
allocator and claimed_address may not be implemented in specified zone.
Add fallbacks for both.

This logic is identical to the Chromium equivalent shim in
base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc

Bug:b/270620301
Change-Id: I4a788d4fbc7b324caff18e41618a5f999b4b8d4e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4549684
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-05-22 17:29:35 +00:00
Justin Cohen
c21292dd71 Fix iOS test with libc++ exception throw change.
After https://reviews.llvm.org/D141222 exceptions call into
__libcpp_verbose_abort, which Chromium sets to `brk 0` in release.

Bug: 1425429
Change-Id: Ie00d1317bb03fcb1f15fb5c41ab69640dfb564b7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4347775
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2023-03-20 19:12:25 +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
Joemer Ramos
3e54a2cd1b ios: Support minimum deployment targets of iOS15
The windows property of UIApplication is unavailable in iOS15.

Bug: 1406561 crashpad:
Change-Id: I19642067a13801142cd3f24586bab6958a81635d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4304398
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Joemer Ramos <joemerramos@chromium.org>
2023-03-03 19:56:37 +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
Avi Drissman
1e10a2370e Update header includes for /base/functional in Crashpad
bind.h, callback.h, callback_forward.h, and callback_helpers.h
moved into /base/functional/. Update the include paths to
directly include them in their new location.

Bug: chromium:1364441
Change-Id: I23aaa16644c10ac5b607ea29d25799fbb08dfaca
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4163072
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
2023-01-13 19:47:47 +00:00
Justin Cohen
b00da64ac8 ios: Correct iOS forbidden allocators on iOS 16.1
There's a new try_free_default in malloc zone 13, and tests now need to
replace zone functions in all zones, not just the default zone.

Change-Id: I5a9893a73f8c9f7068e52bf25f57632f9e409aa2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3934555
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-10-05 17:39:16 +00:00
Ben Hamilton
ca3cf2f4e3 [ios] Add an optional upload complete observation callback to the in-process handler
Breakpad offers a callback when uploads complete:
    https://source.chromium.org/chromium/chromium/src/+/main:third_party/breakpad/breakpad/src/client/ios/BreakpadController.h;l=103;drc=1fc9cc0d0e1dfafb8d29dba8d01f09587d870026

This adds an equivalent observation callback to Crashpad on iOS which is invoked each time an upload attempt completes (whether it succeeds or fails).

I couldn't find any existing unit tests for the upload thread, but
I tested this manually by integrating it into a client. Please
let me know the best way to test this.

Change-Id: I17822af5e63c8634484606a6470ce83b2c385676
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3852399
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2022-09-12 23:08:02 +00:00
Mark Mentovai
6278690abe Update copyright boilerplate, 2022 edition (Crashpad)
sed -i '' -E -e 's/Copyright (.+) The Crashpad Authors\. All rights reserved\.$/Copyright \1 The Crashpad Authors/' $(git grep -El 'Copyright (.+) The Crashpad Authors\. All rights reserved\.$')

Bug: chromium:1098010
Change-Id: I8d6138469ddbe3d281a5d83f64cf918ec2491611
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3878262
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-09-06 23:54:07 +00:00
Alex Pankhurst
6c6c2ae563 [fuchsia] migrate test to CFv2
Fuchsia is undergoing a change to how programs are run and the Crashpad
tests must be migrated to the new system.

Bug: fuchsia:102371

TESTED=`fx test crashpad-test` (540 passing, 1 skipped)

Change-Id: I4daf7d160045b28b876a5f1aa93b0bd596461e0d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3817783
Commit-Queue: Alex Pankhurst <pankhurst@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-08-08 19:03:20 +00:00
Justin Cohen
1424632592 ios: Fix testCrashWithDyldErrorString on arm64.
Fixed when running a simulator on arm64 Apple Silicon.

Change-Id: I6a6e917b4d5ff009683214794fe6a6af833be3c0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3758362
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-07-13 17:32:23 +00:00
Justin Cohen
80f383327e [win] Fix ScopedSetThreadName for Windows 7
Windows 7 doesn't support SetThreadDescription/GetThreadDescription. Add
an IsSupported to ScopedSetThreadName test to wrap unsupported calls.

Change-Id: I70d4e20b94efea03e41c5f7ed8d8e1b886192923
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3722556
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-06-27 17:55:06 +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
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
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
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
8c7caef421 ios: Don't report preprocessed NSExceptions until the uncaught handler.
Change the ObjExceptionProcessor to write intermediate dumps to a
temporary location until they are confirmed by the
UncaughtExceptionHandler. Because the exception preprocessor uses
heuristics to detect iOS sinkholes, it's possible for an exception to
be identified as fatal, but not actual trigger the uncaught exception
handler. If the processor detects more than one fatal exception, it will
unregister itself and indicate this in the second dump with the key
'MultipleHandledUncaughtNSException'.

This changes also consolidates and simplifies some methods in the
InProcessHandler.

Change-Id: Ifc457e974d25f533b77cfd18b702129fdfb10a75
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3529968
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-25 22:35:58 +00:00
Justin Cohen
9c1719802f ios: Replace RawLog FileHandler instead of using freopen for tests.
Previous commits[1][2] modified tests to require looking at RawLog
output to validate the success or failure of the iOS InHandlerProcess.
Previously this would use freopen to direct the RawLog to a file.
However, freopen introduces a race where the log file may not be
associated with stderr, and instead may interfere with the
InProcessHandler's cached writer fd. This caused flake with the
intermediate dumps sometimes including stderr logging.

Since the test fixtures only needs to know about the output of RawLog,
instead add a crashpad::internal::SetFileHandleForTesting method to
that swaps out STDERR_FILENO with the test fixture's fd.

[1] https://crrev.com/c/3488826
[2] https://crrev.com/c/3401563

Change-Id: I87b1020db6b896a47bec5a7c916a572c192b884f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3517773
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-15 17:10:30 +00:00
Justin Cohen
12b35ebde8 ios: Add forbidden allocator to integration tests.
Override malloc_default_zone and malloc_default_purgeable_zone
with allocators that exit when called from the signal or Mach exception
threads in XCUITests, to verify the allocator is not used by the
InProcessHandler. Check stderr for error messages to confirm failures.

Change-Id: I1bb92e57504d71bbf6c6eaad3571c814e8a6934c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3488826
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-10 18:08:46 +00:00
Justin Cohen
3c4e37178d ios: Fix up concurrency in DumpWithoutCrashing and exception handling.
Change signal, uncaught NSExceptions and Mach exception handlers to
prevent re-entrancy with a first-exception-wins approach to prevent
concurrent exceptions from trying to use the same cached intermediate
dump writer.  Uses compare-and-swap to either return early for reentrant
signals or to wait indefinitely for anything after the first fatal
exception.

Change the NSException handler generated from the Objective-C exception
preprocessor to not used the cached intermediate dump writer and
not use the same first-exception-wins logic. This is useful because the
Objective-C exception preprocessor is imperfect and may generate
intermediate dumps that are not followed by process termination.

Simplify DumpWithoutCrashing's ownership of its intermediate dump writer
to be thread safe.

Set a handler for SIGPIPE for applications that haven't already
ignored or set a handler for SIGPIPE.

Bug: crashpad:391
Change-Id: Ia8ae61d50be81910fa0af40325300441d9dc01b6
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3401563
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-10 18:05:16 +00:00
Daniel Cheng
0affe61689 Migrate base::{size,empty,data} to STL equivalents in crashpad.
Bug: chromium:1299695
Change-Id: I95187a425b08c96430c659f843c379d506972f0f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3496462
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-03-01 12:06:49 +00:00
Justin Cohen
30d302a8ca ios: Speed up XCUITests by swizzling away Xcode crash check.
Change-Id: Iadda950544448d771960d35fd064f5287bce0484
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3410579
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-01-26 20:12:31 +00:00
Justin Cohen
b25b523d30 ios: Simplify testBadAccess by removing optimizations.
The badAccess test may return different mach exception codes depending
on optimization levels. Simplify by this by turning off optimization
for this particular test.

Also removes testSegv, which was duplicative and not really testing
SIGSEGV.

Change-Id: Idb92731da6a86545ed83c2bbdd200a0b792c579f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3403040
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-01-21 04:14:57 +00:00
Mark Mentovai
50ed179e9a Use BUILDFLAG for OS checking
Use BUILDFLAG(IS_*) instead of defined(OS_*).

This was generated mostly mechnically by performing the following steps:
 - sed -i '' -E -e 's/defined\(OS_/BUILDFLAG(IS_/g' \
                -e 's%([ !])OS_([A-Z]+)%\1BUILDFLAG(IS_\2)%g' \
       $(git grep -l 'OS_'
         '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm')
 - sed -i '' -e 's/#ifdef BUILDFLAG(/#if BUILDFLAG(/' \
       $(git grep -l '#ifdef BUILDFLAG('
         '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm')
 - gsed -i -z -E -e \
       's%(.*)#include "%\1#include "build/buildflag.h"\n#include "%' \
       $(git grep -l 'BUILDFLAG(IS_'
         '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm')
 - Spot checks to move #include "build/buildflag.h" to the correct parts
   of files.
 - sed -i '' -E -e \
       's%^(#include "build/buildflag.h")$%#include "build/build_config.h"\n\1%' \
       $(grep -L '^#include "build/build_config.h"$'
         $(git grep -l 'BUILDFLAG(IS_'
           '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm'))
 - Add “clang-format off” around tool usage messages.
 - git cl format
 - Update mini_chromium to 85ba51f98278 (intermediate step).
   TESTING ONLY).
 - for f in $(git grep -l '^#include "build/buildflag.h"$'
              '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm'); do \
       grep -v '^#include "build/buildflag.h"$' "${f}" > /tmp/z; \
       cp /tmp/z "${f}"; done
 - git cl format
 - Update mini_chromium to 735143774c5f (intermediate step).
 - Update mini_chromium to f41420eb45fa (as checked in).
 - Update mini_chromium to 6e2f204b4ae1 (as checked in).

For ease of review and inspection, each of these steps is uploaded as a
new patch set in a review series.

This includes an update of mini_chromium to 6e2f204b4ae1:

f41420eb45fa Use BUILDFLAG for OS checking
6e2f204b4ae1 Include what you use: string_util.h uses build_config.h

Bug: chromium:1234043
Change-Id: Ieef86186f094c64e59b853729737e36982f8cf69
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3400258
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-01-19 20:21:19 +00:00
Justin Cohen
243e1fd8e2 ios: Set EXC_SOFT_SIGNAL for signal exceptions.
Right now there's no clear way to differentiate between Signal and Mach
exceptions. Instead, set EXC_SOFT_SIGNAL as the top level exception for
signal exceptions, moving the signal number to ExceptionInfo() and
and the signal code plus the two previous values into Codes().

Fixed:crashpad:389
Change-Id: Ia57f402b98be2a648febb58b9dee0cb80d9e5954
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3388874
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-01-15 03:49:11 +00:00
Avi Drissman
23375ab37c Use std::ignore rather than ignore_result in Crashpad
Bug: 1285085
Change-Id: I02f1eb608a704fe58b72c094b96af6c7577be4bf
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3373171
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
2022-01-07 22:38:52 +00:00
Justin Cohen
c7ce2e3ec1 ios: Tighten up UIGestureEnvironment exception detection.
iOS 15.1 reordered private APIs before public APIs when looking at the
unw_get_proc_info() frame_info.start_ip, so doing a min/max within
UIGestureEnvironment would fail on devices. However, this API is always
called by UIWindow sendEvent, which is not a private API. Do the same
check, but instead look back 2 frames, and check to see if we are
within UIWindow.

Both APIs are still marked <redacted>, but the detection should still
work.

Also cleans up some tests fixtures when running in release.

Change-Id: I762615e9cb44389800cf3291af52a7568c3825d5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3299008
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2021-11-23 20:57:00 +00:00
Peter Boström
bede7bb29e Rename "base/macros.h" => "base/ignore_result.h"
This pulls in "base/ignore_result.h" from mini_chromium through DEPS and
updates existing uses of "base/macros.h" to use "base/ignore_result.h".

Bug: chromium:1010217
Change-Id: I283e2bcfb2775de420d7e767b3b4a639dbba9e20
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3286105
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
2021-11-16 21:21:28 +00:00
Justin Cohen
6fd38ffedf ios: Add exception preprocessor sinkhole for CoreAutoLayout.
Another set of iOS redacted sinkholes appear in CoreAutoLayout.
However, this is often called by our code, so it's unsafe to simply
handle an uncaught nsexception here. Instead, skip the frame and
continue searching for either a handler that belongs to us, or another
sinkhole.

Bug: crashpad: 31
Change-Id: I20be2acef96f5ee6b7521144548e920e635f0dc7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3261270
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-11 03:54:23 +00:00
Justin Cohen
d4bdb997a6 ios: Store Crashpad client annotations in the intermediate dump.
The iOS crashpad client was mistakenly setting the process annotations
(typically things like version and product name) when converting the
intermediate dump into a minidump.  This is incorrect, as those
annotations are determined at intermediate dump creation time.

Instead, correctly write those annotations during intermediate dump
creation. Passing extra annotations during intermediate dump to
minidump is still supported.

Bug: crashpad: 31
Change-Id: Ic5e29debdc123011d130f75a48345071575466d9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3266127
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-10 18:23:41 +00:00
Justin Cohen
fad3bdcde0 ios: Update XCUITests to check various crash type exception codes.
Bug: crashpad:31
Change-Id: I804def3be0050b3e6f15d7d77d0b70184c380673
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3087722
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-10-28 21:37:59 +00:00
Justin Cohen
9747e05e7a ios: Move ios_xcuitest_test to ios_test_runner_xcuitest
This template will allow these tests to run on the Chromium bots.

Change-Id: I3d9ee46379eed104fb847a9a8c1d72462cd67af8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3245731
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2021-10-26 16:52:35 +00:00