Currently, these tests take a pointer to a stack variable to get
an address in the stack. ASAN recently enabled `detect_stack_use_after_return` by default, which breaks this approach.
Bug: chromium:1319307
Change-Id: Ia828a92389cf0d45f31f9a7b999badea398f56ec
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3838735
Reviewed-by: Mark Mentovai <mark@chromium.org>
dyld4 *does* record a timestamp for the main executable (confirmed with
a test app).
Bug: chromium:1268776
Change-Id: I13380181903be7b4886dfdf37f1aa42018a0ef55
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3833512
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
ASAN passes locally for me with this patch in Chromium, so re-enabling
it upstream as well.
Bug: chromium:1334418
Change-Id: I9c9b20d7c309795cb147656374bae1229be6b418
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3833503
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Checking for code-corruption is an important process in crash analysis
so it is important to record code bytes first. This was already done for
ARM and other processors so this change just moves EIP/RIP to the top of
the list.
This is important in scenarios where only a small amount of extra memory
is recorded such as in the stable channel of Chrome.
Bug: 1339513
Change-Id: I26367214ee66795c81000a0487987a130f2ea23a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3812374
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Adds a 4K buffer to the intermediate dump writer. Aside from the final
flush, only write in multiples of 4K. This saves between 30ms and 50ms
on an iPhone 12 Pro.
Change-Id: Icc4b222477bd91fd6952c7cf43b105e1f7a50adb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3764243
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
GCC does not allow binding a packed field to an address. Assign
to a intermediate variable instead before pushing to map.
Bug: chromium:819294
Change-Id: I806e5f99c2b19e656b91a60f72172b59c961ba5f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3751392
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
This adds a runtime exception helper (& test module) for Windows and
plumbing to allow the module to be registered by the crashpad client,
and to trigger the crashpad handler. Embedders can build their own
module to control which exceptions are passed to the handler.
See: go/chrome-windows-runtime-exception-helper for motivation.
When registered (which is the responsibility of the embedding
application), the helper is loaded by WerFault.exe when Windows
Error Reporting receives crashes that are not caught by crashpad's
normal handlers - for instance a control-flow violation when a
module is compiled with /guard:cf.
Registration:
The embedder must arrange for the full path to the helper to
be added in the appropriate Windows Error Reporting\
RuntimeExceptionHelperModules registry key.
Once an embedder's crashpad client is connected to a crashpad
handler (e.g. through SetIpcPipeName()) the embedder calls
RegisterWerModule. Internally, this registration includes handles
used to trigger the crashpad handler, an area reserved to hold an
exception and context, and structures needed by the crashpad handler.
Following a crash:
WerFault.exe handles the crash then validates and loads the helper
module. WER hands the helper module a handle to the crashing target
process and copies of the exception and context for the faulting thread.
The helper then copies out the client's registration data and
duplicates handles to the crashpad handler, then fills back the various structures in the paused client that the crashpad handler will need.
The helper then signals the crashpad handler, which collects a dump then
notifies the helper that it is done.
Support:
WerRegisterExceptionHelperModule has been availble since at least
Windows 7 but WerFault would not pass on the exceptions that crashpad
could not already handle. This changed in Windows 10 20H1 (19041),
which supports HKCU and HKLM registrations, and passes in more types of
crashes. It is harmless to register the module for earlier versions
of Windows as it simply won't be loaded by WerFault.exe.
Tests:
snapshot/win/end_to_end_test.py has been refactored slightly to
group crash generation and output validation in main() by breaking
up RunTests into smaller functions.
As the module works by being loaded in WerFault.exe it is tested
in end_to_end_test.py.
Bug: crashpad:133, 866033, 865632
Change-Id: Id668bd15a510a24c79753e1bb03e9456f41a9780
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3677284
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
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>
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>
The Chromium presubmits flagged a missing #include in
process_reader_win_test.cc. This adds the missing #include.
Change-Id: I68aed4328f976bba547a0cb7a9ea833fdf71873b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3703312
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Fuchsia's Crashpad roller was broken due to uninitialized fields in
structs.
Bug: fxbug.dev/101498
Change-Id: I1283afea9c5ac4eddb432590f9a5ec5cb1856a7c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3704517
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Pankhurst <pankhurst@google.com>
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>
To support MINIDUMP_THREAD_NAME_LIST (which uses 64-bit RVAs for the
thread name MINIDUMP_STRING), this adds minidump string writing and
reading support for the new 64-bit RVA64 and
MINIDUMP_LOCATION_DESCRIPTOR64 types.
Bug: crashpad:327
Change-Id: Iffefffef358517dfc6deac02051dff9dbb8eb214
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3673779
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
Crashpad annotation names are currently limited to 64 bytes.
Breakpad supports up to 256 bytes, so for compatibility with existing
clients, this increases the maximum annotation name size from 64 to
256 and adds new tests to confirm the maximum name and value sizes.
Change-Id: Ib7954bea96046b6b7e18ed9743fe2a15dd3dabac
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3655975
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
IOSIntermediateDumpWriter::Close() is intended to close the FD opened
by the in-process handler.
Currently, InProcessHandler::ScopedLockedWriter::~ScopedLockedWriter() does invoke IOSIntermediateDumpWriter::Close().
However, InProcessHandler::Initialize() invokes the utility CreateWriterWithPath() which directly creates an IOSIntermediateDumpWriter. It neither uses ScopedLockedWriter nor invokes Close().
This fixes the issue by:
1) Making IOSIntermediateDumpWriter::~IOSIntermediateDumpWriter() DCHECK() that it's closed
2) Calling IOSIntermediateDumpWriter::Close() from InProcessHandler::~InProcessHandler() and from test files
Change-Id: Ibfede0a3d2aeac948c7ff3d56445e13d1a4028b5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3648710
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Some xstate flags are not available in arm64 as it does not have
xstate so we should omit the InitializeXState method on the
`target_cpu = arm64` configuration.
Bug: 1250098
Change-Id: I5c92d6efbe90587bdebef87d4a6ce4e9b25afa4d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3653575
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Windows extended contexts must be allocated by InitializeContext2 and
may not be aligned. This means we cannot simply store a struct in
our thread snapshot object, but must instead store enough memory
and alias our struct onto this backing memory.
Note that shadow stack pointers are not yet recorded for the initial
exception - this cannot be determined using LocateXStateFeature in
the capturing process and will be added in a future CL by plumbing
through client messages when a crashed process requests a dump.
See crash/32bd2c53a252705c for an example dump with this baked into
chrome, that has passed through breakpad without breaking it. Local
testing shows this creates valid dumps when built into Chrome, but
that the referenced memory limits may need to be increased to allow
for ssp referenced memory to be included.
See "MANAGING STATE USING THE XSAVE FEATURE SET" Chapter 13 in the
Intel SDM[0]. Many of the offsets and sizes of the extended features
are provided by cpu specific values. We can access these in Windows
using the SDK, and transfer these to the saved extended context
which in turn is understandable by windbg.
Further information is available from AMD Ch. 18 "Shadow Stacks"[1].
[0] https://software.intel.com/content/www/us/en/develop/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4.html.
[1] https://www.amd.com/system/files/TechDocs/24593.pdf
Bug: 1250098
Change-Id: I4b13bcb023e9d5fba257044abfd7e251d66a9329
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3300992
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
This will be used in a later CL to shuttle shadow stack information
from capture to minidumps. For now these fields are zeroed and have
no effect on any platform.
The x64 snapshot context we use no longer directly maps to the early
CONTEXT structure used by Windows (the prelude still matches). This
may cause confusion if people use the size of a snapshot context when
they meant to use sizeof(CONTEXT).
Bug: 1250098
Change-Id: Idac7d888b9e606ceb250c4027e0e7f29f4c0a55f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3536963
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
__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>
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>
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>
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>
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>
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>