652 Commits

Author SHA1 Message Date
Alex Gough
a5b7e504c6 Thread snapshots on Windows can have varying size
In a future CL we will make use of InitializeContext2 which can produce
contexts of varying sizes - this makes the existing use of a union for
wow/x64 contexts no longer feasible.

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

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

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

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

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

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

Bug: 1250098
Change-Id: I933e80e56714a1d8988deae3aa56ec36ed98ef03
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3538665
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2022-04-18 22:36:49 +00:00
Justin Cohen
dedbc0f61b Update Crashpad bot scripts to python3.
Change-Id: Ie3848c2f2bbbe34ca3a5e7da5e7d05e3cfba5b72
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3549021
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-25 22:34:48 +00:00
Justin Cohen
f88a116c0e Update Crashpad scripts to python3
Also update mini_chromium to f87a38442a9e for python3 changes.

Change-Id: I4ca7aa4cc9dcc97698fc0bc13cfb339421668074
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3542572
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-03-24 02:50:56 +00:00
Ben Hamilton
9476a76dc0 win: Use RegOpenKeyExW() instead of RegOpenKeyEx()
Similar to crrev.com/c/3516536, this CL fixes the Windows build
when the UNICODE preprocessor macro is not defined where
code passes Unicode string literals with L"..." to non-Unicode
APIs like RegOpenKeyEx().

This fixes the build by explicitly using RegOpenKeyExW() instead.

Change-Id: I14a827357b9cbd42452e0e5eb13a3430569559a5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3516538
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-03-10 23:10:26 +00:00
Ben Hamilton
ab43d794a6 win: Use RegQueryValueExW() instead of RegQueryValueEx()
crrev.com/c/3434090 introduced a change that breaks the Windows build
when the `UNICODE` preprocessor macro is not defined, as it passed
a `wchar_t*` to `RegQueryValueEx()`.

This fixes the build by explicitly using `RegQueryValueExW()` instead.

Change-Id: Ic438bd982fdeffba05b4224051242b45e797ebd8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3516536
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-03-10 21:04:06 +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
2bb6f068a8 Fix off-by-one error in ModuleSnapshotMinidump DebugFileName.
Strings in minidumps are typically NUL-terminated
(https://docs.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_string).
But the CodeViewRecord types do not use MINDIUMP_STRINGs, and do not
have a separate length field for the pdb_name. Instead, the strings are
always NUL-terminated, with the length derived from the
MINIDUMP_LOCATION_DESCRIPTOR::DataSize field. The writer is correctly
NUL-terminating the debug filename, but ModuleSnapshotMinidump is
off-by-one and including the NUL-terminator.

Change-Id: I8d813b5ef9e9e167dca73a6a938fbbf8dd1580c2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3482876
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-02-24 21:55:20 +00:00
Ben Hamilton
e9937cb36c [Cleanup] Fix circular dependency on Windows.
Crashpad currently has a circular dependency: client->snapshot->client.

The dependency from snapshot -> client only exists to pull in a single
constant for Windows (CrashpadClient::kTriggeredExceptionCode), so this
change breaks the dependency by splitting the constant out into a new
file util/win/exception_codes.h.

Change-Id: I6b74b367df716e097758e63a44c53cb92ea5e04d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3450763
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-02-17 19:33:24 +00:00
Bruce Dawson
be4fb6a412 win: Get correct version info from registry
kernel32.dll no longer works as a source of truth for Windows versions
because it is not updated with every Windows update. This change grabs
the last two version numbers from the registry, if possible.

This also copies some code cleanup from Chromium (crrev.com/c/3205913).

Bug: chromium:1248324
Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3434090
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
2022-02-10 18:00:58 +00:00
André Kempe
45cc0da93a arm64: Add Armv8.3-A PAC support to assembly files
This patch adds optional support for Arm Pointer Authentication Codes.

X30/LR is not stored to stack at any place and restored for usage.
Therefore only adding PAC flag to .note.gnu.property section.

Change-Id: I9581059dfa1eed88af5a73df15b6a0d299caea13
Bug: crashpad: 1145581
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3440070
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org>
2022-02-08 08:42:05 +00:00
Justin Cohen
36ad571862 ios: Add MemorySnapshotIOSIntermediateDumpTest.
Change-Id: Ib8b962c631d6ae90fb1805dff5e28ab078940328
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3401570
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-01-26 21:58:40 +00:00
Joshua Peraza
667424894f linux: re-order first-chance-handlers, and disabled signal handlers
Both running first chance handlers and checking for disabled signal
handlers should no longer interact with DumpWithoutCrashing().

First-chance-handlers should also run even with disabled crashpad
signal handlers or else those signals would be reported by the next
chained signal handlers as crashes.

Change-Id: I64b3da42c400a1c431c6228d4da181ed56bfda89
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3403413
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2022-01-20 17:23:26 +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
b714b223ad ios: Actually merge memory snapshot data.
To avoid unnecessary duplication of potentially large memory regions,
the iOS MemorySnapshot data is owned by the intermediate dump. When
merging two iOS memory snapshots, it's necessary to copy the merged
data into a vector owned by the memory snapshot itself.

Previously the merged snapshot just contained the original data, which
leads to a heap overrun.

Bug: 1288544
Change-Id: I4eb392800141451db188d17c7b9f9ca9bd3bb603
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3399252
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-01-19 00:00:04 +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
Roland Bock
ee230eef02 Replace FALLTHROUGH macro with C++17 [[fallthrough]] attribute
See go/chromium-lsc-fallthrough

Bug:1283907
Change-Id: I786f3e7141ad47913043136d0173e3b82b223a87
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3370128
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-01-07 19:26:52 +00:00
Joshua Peraza
b03c11533c Remove unnecessary lines in CaptureMemoryDelegate
Change-Id: I172c5bf9f399791a9bfecd26553450a2ed30315b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3342502
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2021-12-15 19:29:00 +00:00
Adrian Danis
398908903e Fuchsia: Migrate to zx_system_get_page_size
Bug: fuchsia:67899
Change-Id: Id6fb9f67316dd60c939d9b8b6c6d9330831a04a2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3331859
Reviewed-by: Francois Rousseau <frousseau@google.com>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2021-12-14 03:18:50 +00:00
Joshua Peraza
a253f320d5 linux, win: allow disabling extra memory collection
Change-Id: If95c89d554c061522627681af78c8c0d1725df2c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3335359
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-12-13 22:25:03 +00:00
Salome Thirot
fe19de6e1d arm64: Add Armv8.5-A BTI support to assembly files.
Change-Id: Ic9c2d252829a39b0331e436df16effe7d0607996
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3241142
Commit-Queue: Jonathan Wright <jonathan.wright@arm.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-12-01 10:47:56 +00:00
Justin Cohen
0453ea1686 ios: Handle empty stack in GenerateStackMemoryFromFrames.
This fixes a _LIBCPP_ASSERT vector[] index out of bounds error, caught
by fuzzer.

Bug: 1274178
Change-Id: I95f3fbe450209a24ccc0229741ea752990e18ed6
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3307697
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-29 21:36:05 +00:00
Justin Cohen
bc138fc01c Initialize process snapshot client ids to zero.
Change-Id: If6e1902d62e6364114a75d8ebc4d260e4239d58b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3296266
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-23 20:59:19 +00:00
Justin Cohen
54f2581bf1 ios: Set client id in minidump.
Change-Id: Ie19e0388cf388533b82625a27f7a7a1c2abdaecb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3294662
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-22 21:28:28 +00:00
Justin Cohen
3a7e935a86 ios: Handle partial intermediate dumps and exception contexts.
Testing in beta has shown a few examples of a cropped intermediate dump
still providing useful information, but due to the order intermediate
dump data is written, could be improved.

- Change the order of writing data to the intermediate dump by
increasing the priority of the Exception block from:
 Header / Process / System / Threads/ Modules / Exception
to
 Header / Process / System / Exception / Threads / Modules

- Annotate minidump reports generated from incomplete intermediate
dumps with the key 'crashpad_intermediate_dump_incomplete'.

- Handle partial exception contexts rather than throwing them away.

Change-Id: I543c1d3135c42e5b8e339e498ea0c86002f37ea3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3294862
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-22 21:07:13 +00:00
Justin Cohen
4b86b27773 ios: Add IOSIntermediateDumpInterface.
Change IOSIntermediateDumpReader to take a new interface that can be
backed by a FilePath (as it is now) or a StringFile byte array, which
can be useful for tests, especially with fuzzing.

Change-Id: I02a25cfb7cd204975d1bcce80201bd10944f3f2e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3270755
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-21 04:29:36 +00:00
Robert Sesek
10e82d5318 mac: Make crashpad build with the 12.0 SDK
The size of dyld_all_image_infos didn't change, but the last 128 bit
of `reserved` moved out of `reserved` and got names.

On 64-bit, that's straightforward -- just move two uint64s out of the
array into fields.

On 32-bit, it's fairly awkward: It's 4 of the uintptr_t `reserved`
array, which means `UIntPtr, reserved, [4]` would have to diverge
between 32-bit and 64-bit, and also shared_cache_fs_obj_id would
straddle the `end_v14` boundary. Since macOS 12.0 doesn't support
32-bit builds, just punt on this for 32-bit. (This might possibly
mean that crashpad-on-apple-watch might not compile, but that's
a build configuration that doesn't exist.)

See comment 9 and 6 on the bug.

Bug: crashpad:375, chromium:1265179
Change-Id: I221af20c59c30a8176d5685d3f5e84aaf3de9afe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3253742
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Message-Id: Merged from chromium 83a01b8e2cd2d4d96b0e298d012bb3a2bd93c64f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3293642
Commit-Queue: Robert Sesek <rsesek@chromium.org>
2021-11-19 21:22:55 +00:00
Jakob Kummerow
08978c7b75 Linux: Add a test for "extra memory" / code-around-pc
And implement ExtraMemory() for ProcessSnapshotMinidump for this purpose.

Bug: crashpad:10,crashpad:30
Change-Id: I889c42c7e91358336671ae8d00154af820725e7b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3279301
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
2021-11-16 21:36:03 +00:00
Jakob Kummerow
d62cc6fdbd Linux: capture memory pointed to by context
This adds support for capturing memory snippets for addresses
currently stored in registers to Linux/Android/CrOS.
Modeled after the existing support on Windows.

Bug: crashpad:30
Change-Id: Ib7cb523555a6e8e4d70145c205d67dcfbc9c7fcc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3273712
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-11-12 18:15:04 +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
4bf79bc2bf ios: Fix typo in checking thread_times values.
Change-Id: I4199b5b149d7792dcfb8a3b8de571026b1e98521
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3264806
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2021-11-06 02:17:24 +00:00
Peter Kasting
defcda0c2c Fix an instance of -Wshadow.
Bug: chromium:794619
Change-Id: I504c2931e19f7de4f9d65227fc55978622d0de6f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3253960
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
2021-10-30 23:18:20 +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
Peter Kasting
2c45d05875 More -Wshadow fixes.
Bug: chromium:794619
Change-Id: I1987eb543d0b1a5f82eeb8504b6adde8ef6df600
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3238894
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-10-25 14:42:24 +00:00
Justin Cohen
204abe16d2 ios: Add iOS in-process handler for managing minidump generation.
Manage the intermediate minidump generation, and own the crash report
upload thread and database.

Change-Id: I272d790a827cd13f6872e56f4675f366d13719c5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3087721
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-10-14 15:16:02 +00:00
Joshua Peraza
0a8985cd20 linux,arm: support memory tagging
64-bit ARM's Top-Byte-Ignore enables features such as memory tagging.
https://www.kernel.org/doc/html/latest/arm64/tagged-address-abi.html

Android 11 will start using memory tagging on some devices.
https://source.android.com/devices/tech/debug/tagged-pointers

Crashpad needs to remove the tags from pointers before comparing to
addresses or using with system calls.

Bug: crashpad:364
Change-Id: I67c6b9a4a86d090e1d139de727eb06d9e222cc25
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3078500
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2021-10-13 21:23:34 +00:00
Peter Kasting
dd53970380 Fix an instance of -Wunused-but-set-variable.
Bug: chromium:1203071
Change-Id: I055432e2652ce6ca8a57a6f0f4f584c3e9c511bc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3217911
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
2021-10-11 19:38:29 +00:00
Peter Boström
1aa478d161 Remove DISALLOW_* macros in crashpad
This change was partially scripted and partially done manually with vim
regex + manually placing the deleted constructors.

The script change looked for destructors in the public: section of a
class, if that existed the deleted constructors would go before the
destructor.

For manual placement I looked for any constructor in the public: section
of the corresponding class. If there wasn't one, then it would ideally
have gone as the first entry except below enums, classes and typedefs.
This may not have been perfect, but is hopefully good enough. Fingers
crossed.

#include "base/macros.h" is removed from files that don't use
ignore_result, which is the only other thing defined in base/macros.h.

Bug: chromium:1010217
Change-Id: I099526255a40b1ac1264904b4ece2f3f503c9418
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3171034
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
2021-09-21 15:09:44 +00:00
Justin Cohen
40cd1b72cf ios: Migrate ios/snapshot to writing intermediate dumps.
This migrates all the logic that used to live in ios/snapshots that
gathers all the various information during an exception.

Everything in InProcessIntermediateDumpHandler is considered
`RUNS-DURING-CRASH`.

Change-Id: Icc47c9de0f66be2b14a46a13d1038176082a3218
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2920547
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-08-11 17:52:56 +00:00
Joshua Peraza
78bcb55e1c Construct ProcessMemoryLinux using PtraceConnection
Update ProcessMemoryLinux to be constructed from PtraceConnection
instead of being Initialize()d with a pid_t.

This allows consolidating PtraceClient's BrokeredMemory with
ProcessMemoryLinux and providing the PtraceConnection as a alternative
to the memory file (previously only done for brokered connections).

Change-Id: I1363e208030eaf595fb8051e9a2c6b255c1f9886
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3072402
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2021-08-11 15:48:33 +00:00
David Fang
d5d78c1469 [third_party] Make mini_chromium relocatable
This will accommodate moving third_party/mini_chromium around.
The default location is unchanged for now.

There are GN variables that may need to be updated when Fuchsia's source
re-organizes its layout:

* mini_chromium_source_parent : this contains a BUILD.gn with groups and
encloses the mini_chromium_source_root.  This is controlled by the
structure of the project that depends on this project.

* _mini_chromium_source_root : this is what is normally checked out from
git, the upstream source directory

* mini_chromium_import_root : points inside source_root to make GN files
accessible.

This first step breaks out case logic for "if (crashpad_is_in_fuchsia)"
even if the value is unchanged for now.  This will faciliate a smaller
change when Fuchsia re-structures third_party sources.

Change-Id: I09e5362f4be8fdb440e3891422881b1053052341
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3062424
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2021-08-11 15:26:03 +00:00
Nico Weber
058c1c2d9c Fix a few -Wunreachable-code-aggressive warnings
No behavior change.

Bug: chromium:1066980
Change-Id: Ic9485f3244516a4196965d2ebb2bfbc2c62a91d7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3054401
Commit-Queue: Nico Weber <thakis@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-07-27 15:00:08 +00:00
Joshua Peraza
3ae82cd30a Remove gyp
Standalone Crashpad for Android can now be built with gn.

Change-Id: I0ee7f8e1af8c2bc0edb88e93b345abd7d739f33c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3034984
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2021-07-16 17:09:48 +00:00
Mark Mentovai
883a64e8ee mac/arm64: recognize “Apple M1” as a valid CPU vendor
The DTK reported “Apple processor” in this spot, but shipping hardware
now seems to use “Apple M1”. The DTK is no longer relevant, but for some
degree of future-proofing, look for “Apple ” as prefix in the test.

Test: snapshot_test SystemSnapshotMacTest.CPUVendor
Bug: chromium:1222625
Change-Id: I6ead87ebe9aa078ef9a95e5bcc6a9e5ca8c3b55a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2976787
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2021-06-22 15:28:16 +00:00
Justin Cohen
ce378c4293 Fix some chromium roll errors and warnings.
Remove unneeded base/strings/stringprintf.h includes.
ARCH_CPU_X86_64 macro is used without including build/build_config.h
Missing base/check.h

Change-Id: Ib7864ab7b30ef8fc37649783f7b90b618d0d6a0b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2920552
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2021-06-02 22:02:42 +00:00
Justin Cohen
7f6f917aac ios: Migrate ios/snapshot to reading intermediate dumps.
Change-Id: Ib7715e642fa685a5f607239d07dcb68868cacb09
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2883523
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-05-26 19:36:05 +00:00
Lei Zhang
d8f60c8112 Swap from base/stl_util.h to cxx17_backports.h.
Chromium moved base::size() to base/cxx17_backports.h, so do the same in
mini_chromium and update the users in Crashpad.

Roll mini_chromium to 2f06f83f to make the new base header available.

Bug: chromium:1210983
Change-Id: Ie3dc4c189dcdfcac030b95fe285f94abb29a27bf
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2917779
Commit-Queue: Lei Zhang <thestig@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-05-25 21:44:52 +00:00
Francois Rousseau
e841b92e18 fuchsia: clarify stack capture in case of stack overflow
Bug: fuchsia:74897
Change-Id: I1a81feaa2e854c51d7dc476d57b5f7d1ffb1d6e7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2895346
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2021-05-14 00:22:16 +00:00
Justin Cohen
b10f07e52e ios: Extract common targets to be shared for iOS.
Move some common files out of client and handler for iOS usage.

Bug: crashpad: 31
Change-Id: I1933eaaa7580a81017c52b77dfb636a8fa31ee78
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2851059
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2021-04-29 19:52:27 +00:00
Justin Cohen
dc02980481 ios: Move system data collector to internal.
Also fixes a usage of ->assign in the class which will be unsafe to use.

Bug: crashpad:31
Change-Id: I434df35b0669dde2323817f3c0cef1727926c85f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2650088
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-03-29 16:59:37 +00:00
Jan Wilken Dörrie
2872c0ea4e [LSC] Remove base::char16 and base::string16 aliases
This change removes usages of the base::char16 and base::string16 type
aliases in favor of using char16_t and std::u16string directly.

Bug: chromium:1184339
Change-Id: Ieb790cbe2ce98d91865cd21d98616195a57b3903
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2742482
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-03-08 21:08:44 +00:00
Adam Kallai
c7ec0a84cc Use char16_t instead of wchar_t in SystemSnapshotWin
This CL[1] removed the alias declaration for wchar_t
in case of Windows platform. So we cannot call base::UTF16ToUTF8 function
with wchar_t type.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1776026

BUG=chromium:1184955

Change-Id: I07f0e35176ed72df4053d2f70769166e3eebfc63
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2737079
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2021-03-08 15:41:43 +00:00
Rune Lillesveen
57c336371c Add missing dependency on util to fuzzer
This makes it possible to run gn check --deps for crashpad/snapshot in
chromium.

ERROR at //third_party/crashpad/crashpad/snapshot/elf/elf_image_reader_fuzzer.cc:19:11: Can't include this header from here.
#include "util/process/process_memory.h"
          ^----------------------------

Bug: chromium:1159035
Change-Id: Idddcf95da2a349842fa86a8d595216fbca3b8822
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2676581
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-02-04 21:50:02 +00:00
Eric Astor
cce6b30149 Optimize calls to std::string::find() and friends for a single char.
The character literal overload is more efficient.

Change-Id: Ia2ec863e3442b87d357c20f932f88e31d40e6524
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2596067
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Eric Astor <epastor@google.com>
2020-12-16 19:18:09 +00:00
Joshua Peraza
8bf3cdd977 linux: fix build breakage
2f7d40c4 Removed the last usage of ExpectTestModule() in
sanitized builds.

Change-Id: I6a894545f07b1c377f88820893c23a2296d74cc7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2590205
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-12-14 19:13:18 +00:00
Braden Kell
44de18ca37 Fix instances of undefined behavior
This change removes several unaligned accesses, as well a null pointer
offset and an out of bounds array access.

Bug: fuchsia:46805
Change-Id: I0110d0b7faf672655d978894b868760eee7b2988
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2583025
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2020-12-11 19:18:19 +00:00
Joshua Peraza
2f7d40c405 linux: disable test module in more tests
This test was missed in
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2585002

Change-Id: Icf972284d2be02b4dae85611fcb2b5623f677ef2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2586007
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-12-11 18:25:19 +00:00
Joshua Peraza
0886a625cc linux: Disable test module with sanitizers
Clang's sanitizers on Linux might hook dlopen() to track memory regions
mapped by loaded modules, but they depend on shared libraries having a
preferred address of 0 so that the load bias in the link map is equal
to the module's loaded address in memory.

https://code.woboq.org/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp.html#1172

Change-Id: Ice44aa157577d6f97bc7fc0f7e3ef9d5fbaaf46a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2585002
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-12-10 18:19:48 +00:00
Joshua Peraza
83f194ee85 linux: Add linux-gate.so to valid vdso prefixes
The name of the vdso varies by ABI and in particular begins with
linux-gate.so when targeting i386.

Change-Id: Icd9d25aa2ad44b00fed1e4088fe72f77a505f445
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2570143
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-12-04 00:08:45 +00:00
Joshua Peraza
00491d58ee linux: Correct handling of load bias
The load bias is documented to be the difference between
the preferred and actual load address for a module, but
is declared as an unsigned number, and math using it relies
on it being a pointer-precisioned two's complement number
that might cause over- or under-flow.

ElfImageReader and DebugRendezvous both provide ways to get
the load bias for a module and are corroborated in tests.
However, the load bias computed by DebugRendezvous does
not have access to the preferred address, so there is not
enough information to determine the signedness to use with
a VMOffset.

This patch compares the load biases modulo the numeric range
for a pointer to ignore the signedness of the value.

Also update the test module to trigger a negative load bias.

Bug: chromium:1147922
Change-Id: I55bc49195cfb2def06777e26388380fb9bc0f710
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2569886
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-12-03 23:57:25 +00:00
Joshua Peraza
6c270cf239 linux: Refactor test modules
This patch moves LoadModule() to it's own file from
process_reader_linux_test.cc so that it may be used in
other tests that interact with loaded modules.

Change-Id: Ie4f7932d65710fc3e20b6e2488e497c5aab27cdd
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2569882
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-12-03 23:24:15 +00:00
Joshua Peraza
640b13f3cb linux: Don't load section headers of test module
The ELF standard allows substantial flexibility in the construction of
valid ELF modules, but there are widely followed conventions. For
example, ELF modules typically contain several segments, they do load
their program headers, and they don't load their section headers.

Bionic contains a variety of checks that the modules it's loading look
typical. Beginning with Android M, Bionic refuses to load segments which
contain the entire file contents.

Change-Id: I0687a3cfd84b3561112dcd32eb6b96493969695e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2486401
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-26 22:15:52 +00:00
Nico Weber
0e03f8e7fa Remove now-no-op set_sources_assignment_filter calls
After https://chromium-review.googlesource.com/c/chromium/src/+/2426564,
not having a sources assignments filter is the default.

No behavior change.

Bug: chromium:1018739
Change-Id: Ia2e6af0d613d3cbdfe6595bfe1f688c1efd55f39
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2446269
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-02 17:43:39 +00:00
Scott Graham
1c77abe909 fuchsia: Centralize disabling of Wconversion
Because of the multiple-worlds building of the Crashpad code in the
Fuchsia tree (with the Fuchsia BUILDCONFIG.gn in particular) there's no
good location to globally disable Wconversion for all of crashpad.

This can be somewhat-improved by using a GN template
crashpad_static_library() similar to the existing crashpad_executable()
template.

Includes mini_chromium DEPS roll:
68da43e Fix a couple trucation warnings
88ce866 build: set include dirs

Bug: fuchsia:58162
Change-Id: I638fcf858c35b9a858ca2c410636f8c99603aed2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2411131
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2020-09-16 22:25:10 +00:00
Jan Wilken Dörrie
a98ee20e57 [crashpad] Prepare crashpad for base::string16 switch
This change prepares crashpad for the upcoming switch of base::string16
to std::u16string on all platforms. It does so by replacing Windows-only
instances of base::string16 with std::wstring, and using appropriate
string utility functions.

Bug: chromium:911896
Change-Id: Ibb0b8a4e4dc7fae1d24d18823f8dbb6da31f8239
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2332402
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-12 07:36:53 +00:00
Shai Barack
90344b24ed fuchsia: suppress -Wconversion warnings
Bug: fuchsia:56258
Bug: fuchsia:58162
Change-Id: I0b74e1786c169bef4e44ab54a19ffba79063474a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2405375
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-11 22:00:00 +00:00
Mark Mentovai
9a5a789123 mac: Fix MacOSVersionNumber for 10.12.0 < version < 10.13.4
In 5412beb63386, I asserted (via my code) that the kern.osproductversion
sysctl was introduced in 10.12.0, but this was utterly wrong. It’s not
available until 10.13.4. Compare 10.13.3
xnu-4570.41.2/bsd/kern/kern_sysctl.c to 10.13.4
xnu-4570.51.1/bsd/kern/kern_sysctl.c, look for osproductversion.

https://pbs.twimg.com/media/EU0GDTVU4AY73KC.jpg

Failures appeared starting at
https://ci.chromium.org/p/chromium/builders/ci/Mac10.12%20Tests/37499
(https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8869605548532164608/+/steps/crashpad_tests_on_Intel_GPU_on_Mac_on_Mac-10.12.6/0/stdout).

This fixes expectations to not require kern.osproductversion to exist
until 10.13.4.

VM-tested on 10.12.6, 10.13.3, 10.13.4, and 10.14.0.

Bug: crashpad:347
Test: crashpad_util_test MacUtil.MacOSVersionNumber
Change-Id: Ic58d8ca8f04394d41c691dd2d946c59497ee71d5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2402248
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-09-10 13:53:29 +00:00
Mark Mentovai
ca88ff1edb mac-arm64: Don’t attempt to determine the CPU frequency
Apple has never exposed the CPU frequency on ARM systems. Report it as 0
on mac-arm64 without attempting to obtain it from the system (which
would log a warning in the process).

This will resolve these harmless warnings produced when Crashpad creates
a snapshot on arm64:

[pid:tid:yyyymmdd,hhmmss.µµµµµµ:WARNING system_snapshot_mac.cc:50] sysctlbyname hw.cpufrequency: No such file or directory (2)
[pid:tid:yyyymmdd,hhmmss.µµµµµµ:WARNING system_snapshot_mac.cc:50] sysctlbyname hw.cpufrequency_max: No such file or directory (2)

Bug: chromium:1103944
Change-Id: Id6217d5b9f756c54f46a6b29742c361e987412f0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2392076
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 04:10:15 +00:00
Mark Mentovai
df12d57e97 mac: Don’t build 32-bit ProcessReaderMac support where it’s unusable
There is no possibility to run 32-bit processes on macOS 10.15 or later.
There is never any possibility to run 32-bit processes on macOS on
arm64.

This transforms ProcessReaderMac::Is64Bit into a compile-time constant
“yes” when building for a system that will never see a 32-bit process.
This is a lightweight way to get much 32-bit support code removed from
optimized compiled output, including all of process_types. In an
optimized build of crashpad_handler for arm64, this is a 3% reduction
from 569kB to 552kB (-17kB).

Change-Id: I8890a170467834b99b017f1aa3dc78f3f33cd13e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2389010
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 04:08:55 +00:00
Mark Mentovai
0bc3826129 mac-arm64: Allow target_cpu = "mac_universal" to create universal builds
When building for macOS and configured with target_cpu =
"mac_universal", bi-architecture x86_64/arm64 output will be produced.

mac_universal is, so far, a “Crashpad special” that will only work with
mini_chromium and the standalone Crashpad build, and not the in-Chromium
build. It exists to support Keystone, which intends to ship as
x86_64/arm64 universal.

Includes:

Update mini_chromium to e0008f2714a76c7f2a3854fa75774427a886d6b9

e0008f2714a7 mac-arm64: Allow target_cpu = "mac_universal" to create
             universal builds

Bug: crashpad:345
Change-Id: I5ff2dce5ffae58186e33757aa94587f8eca20b99
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2387410
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 04:02:56 +00:00
Mark Mentovai
f8563cb862 mac-arm64: Omit the cl_kernels workaround on this platform
cl_kernels modules have appeared since OS X 10.10 as MH_BUNDLE modules
with a __TEXT segment, one section of which claims to belong to the __LD
segment. They are produced when OpenCL is asked to compile an OpenCL
kernel for the CPU, but this currently appears impossible on arm64.

The workaround is omitted as it appears to be unnecessary, but the test
still attempts to create an OpenCL kernel for the CPU. If this ever
becomes possible, and the modules are malformed, the test will fail as
an indication that the workaround must be reinstated for arm64.

Bug: crashpad:345
Test: crashpad_snapshot_test ProcessReaderMac.{Self,Child}Modules
Change-Id: Ia3d7163cc9995bb4a33457a77c2a5f0e66f4c1a0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2386466
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 03:58:15 +00:00
Mark Mentovai
abfc89bb9b mac-arm64: Set expectations for tests that crash via __builtin_trap
__builtin_trap uses ud2 on x86_64, producing a SIGILL. On arm64, it uses
brk #1, producing a SIGTRAP. Test expectations must be adjusted
accordingly.

Bug: crashpad:345
Test: crashpad_snapshot_test MachOImageAnnotationsReader.CrashModuleInitialization, crashpad_util_test ExcServerVariants.*,ExceptionPorts.*
Change-Id: I22e75b7b48b8887031b1d95f1cea8a09733daf49
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2386464
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 03:41:05 +00:00
Mark Mentovai
5412beb633 mac: Replace MacOSXMinorVersion with MacOSVersionNumber
MacOSXMinorVersion reported just the “y” value for an OS version 10.y.z.
This is no longer sufficient to identify OS versions accurately in macOS
11. A new MacOSVersionNumber function reports the full OS version as
“xxyyzz” for an OS version x.y.z. This is the same format used by
<Availability.h> __MAC_* macros since 10.10.

MacOSXVersion is also renamed to MacOSVersionComponents for
disambiguation and proper modern nomenclature.

Bug: crashpad:347
Test: crashpad_snapshot_test SystemSnapshotMacTest.OSVersion, crashpad_util_test MacUtil.MacOSVersionNumber
Change-Id: I66421954f021c0627095474cb26359970fcd9101
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2386386
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 02:53:35 +00:00
Sean McAllister
3965bc7d78 Refactor OS_LINUX usage for coming LaCrOs update.
We're working to decouple ChromeOS and Linux builds of Chrome.

Currently OS_CHROMEOS sets OS_LINUX, so we need to refactor
current OS_LINUX usage to make this explicit.

More information can be found at go/cros_is_linux_os_linux

BUG=chromium:1110266
TEST=manual build

Change-Id: Ie765da1ab6a0bf0286538ae1df3697abaa29aeaa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2391116
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-09-03 19:12:04 +00:00
Mark Mentovai
b3d84e0d05 mac: System libraries are no longer found on disk on macOS 11
On macOS 11, system libraries are no longer present on disk as
individual Mach-O files, but are shipped exclusively in the dyld shared
cache. This affects tests that verify the list of modules loaded into a
process. The new _dyld_shared_cache_contains_path function can be used
to determine whether a path exists in the dyld shared cache.

Bug: crashpad:347
Test: crashpad_snapshot_test ProcessReaderMac.{Self,Child}Modules
Change-Id: I19402e45701caeb850bdafd701ccbba4ef9c60bc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2384322
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-08-31 21:15:49 +00:00
Mark Mentovai
56937e1df5 mac: 11.0 SDK support
This updates the process_types version of dyld_all_image_infos for macOS
11.0.

Test: crashpad_snapshot_test ProcessTypes.DyldImagesSelf
Bug: crashpad:347
Change-Id: Ieb134f17015070a11c918b26ece316f77a4cc263
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2384317
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-08-31 21:14:59 +00:00
Mark Mentovai
bdf9471324 mac: Switch from <AvailabilityMacros.h> to <Availability.h>
The macOS 11.0 SDK, as of Xcode 12b6 12A8189n, has not updated
<AvailabilityMacros.h> with a MAC_OS_X_VERSION_11_0 or
MAC_OS_X_VERSION_10_16 constant. However, the <Availability.h> interface
has been updated to provide both __MAC_11_0 and __MAC_10_16.
<AvailabilityMacros.h>’s MAC_OS_X_VERSION_MAX_ALLOWED, which is supposed
to identify the SDK version, is broken in the 11.0 SDK in that whenever
the deployment target is set to 10.15 or earlier, the SDK will be
mis-identified through this interface as 10.15. When using the
<Availability.h> equivalent, __MAC_OS_X_VERSION_MAX_ALLOWED, the 11.0
SDK is identified as 10.16 (arguably it should be internally versioned
as 11.0, but at least this interface allows it to be detected
unambiguously.) It’s clear that the <AvailabilityMacros.h> interface
provides no meaningful support for the macOS 11.0 SDK at all, but
<Availability.h> does.

<Availability.h> was introduced in the Mac OS X 10.5 SDK, so there is no
relevant SDK version compatibility problem with this interface.

Key differences between these interfaces for the purposes used by
Crashpad:
 - <AvailabilityMacros.h> → <Availability.h>
 - MAC_OS_X_VERSION_MIN_REQUIRED (DT) → __MAC_OS_X_VERSION_MIN_REQUIRED
 - MAC_OS_X_VERSION_MAX_ALLOWED (SDK) → __MAC_OS_X_VERSION_MAX_ALLOWED
 - MAC_OS_X_VERSION_x_y → __MAC_x_y
 - <Availability.h> __MAC_OS_X_VERSION_* SDK/DT macros are only
   available when targeting macOS, while <AvailabilityMacros.h>
   MAC_OS_X_VERSION_* SDK/DT macros are available on all Apple platforms,
   which may be a source of confusion. (<Availability.h> __MAC_* macros
   do remain available on all Apple platforms.)

This change was made mostly mechanically by:

sed -i '' -Ee 's/<AvailabilityMacros.h>/<Availability.h>/g' \
    $(git grep -E -l '<AvailabilityMacros.h>' |
          grep -v AvailabilityMacros.h)

sed -i '' -Ee 's/(MAC_OS_X_VERSION_(MIN_REQUIRED|MAX_ALLOWED))/__\1/g' \
    $(git grep -E -l 'MAC_OS_X_VERSION_(MIN_REQUIRED|MAX_ALLOWED)' |
          grep -v AvailabilityMacros.h)

sed -i '' -Ee 's/(MAC_OS_X_VERSION_(10_[0-9]+))/__MAC_\2/g' \
    $(git grep -E -l 'MAC_OS_X_VERSION_(10_[0-9]+)' |
          grep -v AvailabilityMacros.h)

Bug: crashpad:347
Change-Id: Ibdcd7a6215a82f7060b7b67d98691f88454085fc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2382421
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-08-31 21:11:29 +00:00
Shai Barack
59e8120e7a [Wconversion] Suppress warnings on Fuchsia
Bug: fuchsia:56258

Change-Id: I6bdc0b81a0294040e4dceb18576ab38c45a430e4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2345384
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2020-08-25 00:09:48 +00:00
Mark Mentovai
1509aadd63 Remove a variable-length array to enable compiling with -Wvla
Change-Id: I721f1dccc7e1188631a57f435c5c097ff83853b8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2363768
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-08-18 21:18:39 +00:00
Mark Mentovai
ebab28f30d Remove a variable-length array* to enable compiling with -Wvla
* that hopefully never actually materialized

Change-Id: Ic8625c0edf773a2dd5f0c40b7f293ec5492ce101
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2363147
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-08-18 15:16:47 +00:00
Joshua Peraza
2f66eefb79 Update language to eliminate 'whitelist'
Change-Id: I6afe27313093c6867d0276274e6b17b195d9d263
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2339536
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-08-06 21:03:16 +00:00
Avi Drissman
4ae896bad0 Migrate to OS_MAC and OS_APPLE in Crashpad
This migrates:

 defined(OS_MACOSX) -> defined(OS_APPLE)
 defined(OS_MACOSX) && !defined(OS_IOS) -> defined(OS_MAC)
 !defined(OS_MACOSX) || defined(OS_IOS) -> !defined(OS_MAC)

Bug: chromium:1105907
Change-Id: I1b4abc19bbbe8df90e9c6e64cd29324b40b8ab71
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2321777
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-28 02:35:48 +00:00
Joshua Peraza
e89ba0d1d6 linux: fix timer test
Semaphore is implemented with a mutex and condition variable.
When a semaphore is used in TimerTest, Run() acquires a lock
to guard its CV but may be interrupted by the signal handler
before releasing the lock which results in a hang when
Signal(), called from the signal handler, also needs to
acquire the lock.

Bug: chromium:1050178
Change-Id: I0d7ef65bd159ee2de9258ba24537f9470f4c621d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2318554
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-07-27 20:48:49 +00:00
Joshua Peraza
ad3ad354d3 android: fix executable name test
Bug: chromium:1050178
Change-Id: I04ba3e4c4b3d2c707a9967b792a2e8d85e62adef
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2317841
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-07-27 16:51:25 +00:00
Scott Graham
ef8a063055 Fuchsia: Propagate failure to initialize exception snapshot
If the process' threads can't be read, then the cpu context object won't
be able to be initialized.

Previously, the process snapshot always assumed that the context would
be filled out, as there was no error returned, which could result in
later checks failing.

Return an error from the exception snapshot's initialization so that
process snapshot can correctly handle failure to initialize.

Bug: fuchsia:55837
Change-Id: Ia3fecef1230a19dfa23401b0339c6a94370c6baf
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2296039
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-13 19:53:06 +00:00
Mark Mentovai
498c36b82a mac arm64: Provide something more useful from SystemSnapshot::CPURevison
hw.cputype is just CPU_TYPE_ARM64, which isn’t terribly useful.
hw.cpufamily is somewhat better as it uses <mach/machine.h> CPUFAMILY_*
values, which distinguish between different CPU generations.
CPUFAMILY_ARM_VORTEX_TEMPEST identifies A12, for example. (The fun cores
are Vortex and the boring cores are Tempest.)

Bug: crashpad:345
Change-Id: I88be4fa0b305b2fa15bd24358f63dc7d72192b27
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2289041
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-07-09 01:48:42 +00:00
Mark Mentovai
0c3f50c8e1 mac: Crashpad for macOS on arm64, phase 2: build tests
This gets all tests building. They don’t all pass, and there aren’t any
guarantees that anything else works yet, either.

This is mostly a lot of CPU context shuffling.

Bug: crashpad:345
Change-Id: I684017a5816f44917392964d7fb6d08083770b38
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2285962
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-07-08 20:26:51 +00:00
Mark Mentovai
809939c9d1 mac: Crashpad for macOS on arm64, phase 1: build it
This gets all production code for Chrome building, excluding tests.
There aren’t any guarantees that anything works yet.

This is mostly a lot of CPU context shuffling.

In contrast to macOS on x86, there’s no need to support 32-bit arm on
macOS, because this new platform is 64-bit-only from its inception.

Bug: crashpad:345
Change-Id: I187239b6a969005a3458af7fe30c44147a57f95f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2285961
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-07-08 16:18:40 +00:00
Tamir Duberstein
d2c22d6b4b [fuchsia] Always initialize
We occassionally see UB here that looks like context_.architecture isn't
initialized.

Note to reviewers: needs a test. Guidance on where/how to write one
would be most welcome.

Bug: fuchsia:55587
Change-Id: I886972e4d3a5c1e0c53eb17f3f65dada47a84115
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2281881
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2020-07-06 23:07:38 +00:00
Adam Kallai
e46f30cc54 fix: include missing header file
Include the header from base/ where NOTREACHED is defined.
This fixes a build failure on Windows on Arm.

The patch was originally created by Richard Townsend <richard.townsend@arm.com>.

Bug: 1100363
Change-Id: Ic97f7c217f22e51f1d4c9bd87ae434e263975c6d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2279091
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-02 18:38:59 +00:00
Robert Sesek
99ecfd3b52 apple: Convert GN libs lists to frameworks.
GN recently added support for Apple frameworks to link, rather than
overloading the libs lists. This pulls .frameworks out of the libs
lists, so that GN can stop supporting .frameworks in libs in the
future.

Roll mini_chromium ae14a14ab..cd26c5101

$ git log ae14a14ab..cd26c5101 --date=short --no-merges --format='%ad %ae %s'
2020-07-01 rsesek@chromium.org apple: Expand {{framework_dirs}} and {{frameworks}} in the toolchain.

Bug: chromium:1052560
Change-Id: Id70bceb57174a52c6f4a7f72378a3ee0ae89f64d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2278022
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
2020-07-01 19:57:26 +00:00
Mark Mentovai
09d1df04bf Use OS_WIN, not OS_WINDOWS; provide crashpad_types traits for Fuchsia
The incorrect macro was used in f4b906c79c02 (at my request when I was
reviewing from a phone).

The Windows and Fuchsia builds are broken, so…

TBR: epastor@google.com
Change-Id: I8aebbbc24db261f3c3377210bb1c477132964828
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2270920
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-27 04:56:14 +00:00
Eric Astor
f4b906c79c Avoid use of a Linux-only header in cross-platform code
Change-Id: I358ee1d7e09868e64df1f1dc6c0f49e40099ff16
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2259336
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-24 17:31:40 +00:00
Eric Astor
d9c3e7cb36 Avoid use of variable-length arrays when not necessary
Change-Id: I45872ed02bbcf49b2709276dbb38cf72fab5cb1c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2259335
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-24 17:27:44 +00:00
Hans Wennborg
161bfed35a Remove/replace unnecessary includes of logging.h
If the file just needs the CHECK/CHECK_OP/NOTREACHED
macros, use the appropriate header for that instead.
Or if logging.h is not needed at all, remove it.

This is both a nice cleanup (logging.h is a big header,
and including it unnecessarily has compile-time costs),
and part of the final step towards making logging.h no
longer include check.h and the others.

Bug: chromium:1031540
Change-Id: Ia46806bd95fe498bcf3cf6d2c13ffa4081678043
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2255361
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
2020-06-22 11:59:03 +00:00
Hans Wennborg
032f1aecc2 Include-what-you-use related to logging.h
Add direct includes for things provided transitively by logging.h
(or by other headers including logging.h).

This is in preparation for cleaning up unnecessary includes of
logging.h in header files (so if something depends on logging.h,
it needs include it explicitly), and for when Chromium's logging.h
no longer includes check.h, check_op.h, and notreached.h.

DEPS is also updated to roll mini_chromium to ae14a14ab4 which
includes these new header files.

Bug: chromium:1031540
Change-Id: I36f646d0a93854989dc602d0dc7139dd7a7b8621
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2250251
Commit-Queue: Hans Wennborg <hans@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-18 13:51:20 +00:00
Joshua Peraza
7a70b0f151 android: correct executable placement in debug rendezvous
On Android P, Bionic mistakenly places the vdso first
in the list where the executable should be.

Also correctly set the section size in the section
headers for test module string tables.

Bug: chromium:1050178
Change-Id: I83581d05c5ed3e25a237d1ce4a27c45755a3ab3c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2231525
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-06-05 02:29:11 +00:00
Joshua Peraza
294d233ca0 elf: adjust small DT_STRTAB addresses by load bias
Change-Id: I7ffbd2be0800aedad8b5c4b6982379e5485f1bc8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2229114
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-04 22:42:57 +00:00