634 Commits

Author SHA1 Message Date
Nico Weber
b1739cc67f crashpad: Remove semicolons, Windows edition.
Bug: chromium:926235
Change-Id: I392675c2f6ad09fbdabbb19c49805f73fa665c7e
Reviewed-on: https://chromium-review.googlesource.com/c/1483310
Commit-Queue: Nico Weber <thakis@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-02-22 17:18:17 +00:00
Petr Hosek
4dbd8c75d5 Fix issues revealed by -ftrivial-auto-var-init=pattern
-ftrivial-auto-var-init=pattern automatically initializes all variables
with a pattern. This revealed two issues:

1. Unitialized read of field from CrashpadInfoClientOptions.
2. The PC distance check in TestCaptureContext (due to additional
instrumentation, the distance is now 76 on x86-64 and 92 on aarch64).

Change-Id: I528e5f21c70d2849c9300776da783fde59411e9e
Reviewed-on: https://chromium-review.googlesource.com/c/1471691
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-02-14 16:41:57 +00:00
Mark Mentovai
bba9d0819c Revert "Use GTEST_SKIP() instead of custom DISABLED_TEST()"
This reverts commit 79f4a3970a6425ef0475263974bf9a012279ba4f.

Chromium’s test launcher is not prepared to handle GTEST_SKIP().

Bug: chromium:912138
Change-Id: Iaeffaedcd92093ec61b013f2a919dc4670094581
Reviewed-on: https://chromium-review.googlesource.com/c/1464099
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-02-11 17:12:40 +00:00
Mark Mentovai
ff5a25e11f Remove a few unnecessary semicolons.
Patch by Nico Weber <thakis@chromium.org>, originally
https://crrev.com/c/1463405.

Bug: chromium:926235
Change-Id: I7e0ba822aa8dd104768d7ad6e603539576ae96a9
Reviewed-on: https://chromium-review.googlesource.com/c/1463744
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
2019-02-11 16:21:20 +00:00
Maksim Sisov
152aa8d1f9 Add missing limits header to crashpad.
This patch fixes the following error:

../../third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc:246:12: error: 'numeric_limits' is not a member of 'std'
       std::numeric_limits<decltype(context->spsr)>::max()) {
            ^~~~~~~~~~~~~~
../../third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc:246:27: error: expected primary-expression before 'decltype'
       std::numeric_limits<decltype(context->spsr)>::max()) {
                           ^~~~~~~~
../../third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc:246:27: error: expected ')' before 'decltype'

Bug: chromium:819294
Change-Id: I4f31a33fcdae9567c71a4d371d2e6afe68d2ef6a
Reviewed-on: https://chromium-review.googlesource.com/c/1454376
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-02-11 10:07:08 +00:00
Matthew Dempsky
1fc95dc3cc [fuchsia] Add zx_vmo_replace_as_executable to tests
Fuchsia in the future will create VMOs as non-executable (i.e.,
without ZX_RIGHT_EXECUTE) by default, so this necessary preparation
for that.

Change-Id: I00ada804d1d16db4f50ff3882058e382b1845328
Reviewed-on: https://chromium-review.googlesource.com/c/1419778
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Matthew Dempsky <mdempsky@chromium.org>
2019-01-22 21:07:06 +00:00
Mark Mentovai
79f4a3970a Use GTEST_SKIP() instead of custom DISABLED_TEST()
Since gtest 00938b2b228f3, gtest has built-in first-class support for
skipping tests, which is functionally identical (at least in Crashpad’s
usage) to the home-grown support for run-time dynamically disabled tests
introduced in Crashpad 5e9ed4cb9f69.

Use the new standard pattern, and remove all vestiges of the custom
local one.

Change-Id: Ia332136c356d523885fc5d86bc8f06fefbe6a792
Reviewed-on: https://chromium-review.googlesource.com/c/1427242
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-01-22 21:00:06 +00:00
Mark Mentovai
6a209070e4 Change deprecated gtest TEST_CASE macros to TEST_SUITE
No functional change. See
https://github.com/google/googletest/blob/master/googletest/docs/primer.md#beware-of-the-nomenclature
(as of 5d3a2cd9c854).

Change-Id: I0f6dc59f014b01d18a09a92f016351a7402d8e6c
Reviewed-on: https://chromium-review.googlesource.com/c/1427499
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-01-22 20:58:58 +00:00
Vlad Tsyrklevich
fe05eb7c99 Update ASan disabled tests to exclude all platforms
Use-after-return detection happens to currently be enabled on Linux and
Android but is not exclusive to those platforms. Disable tests
incompatible with ASan UAR detection on all platforms.

Bug: 915245
Change-Id: I40447c126dac9dc7d0f72e400136afb8c292324d
Reviewed-on: https://chromium-review.googlesource.com/c/1414614
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-01-16 18:56:06 +00:00
Vlad Tsyrklevich
e7895b4404 Include changes from chromium
These changes were made in the upstream version of crashpad without
being contributed back to crashpad.

Bug: crashpad:271
Change-Id: I60f6dfd206191e65bac41978a7c88d06b8c3cee9
Reviewed-on: https://chromium-review.googlesource.com/c/1389238
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-01-09 17:53:44 +00:00
Dave Moore
670dec4b61 [syscalls] Change references to ZX_VM_FLAG_* to ZX_VM_*
Test: Existing
Change-Id: I36fde186de372d2b86807f4da4e6e589a1b19706
Reviewed-on: https://chromium-review.googlesource.com/c/1395479
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2019-01-07 20:47:19 +00:00
Mark Mentovai
cc166d71f4 Use base::size where appropriate, and ArraySize elsewhere
This is a follow-up to c8a016b99d97, following the post-landing
discussion at
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1393921/5#message-2058541d8c4505d20a990ab7734cd758e437a5f7

base::size, and std::size that will eventually replace it when C++17 is
assured, does not allow the size of non-static data members to be taken
in constant expression context. The remaining uses of ArraySize are in:

minidump/minidump_exception_writer.cc (×1)
minidump/minidump_system_info_writer.cc (×2, also uses base::size)
snapshot/cpu_context.cc (×4, also uses base::size)
util/misc/arraysize_test.cc (×10, of course)

The first of these occurs when initializing a constexpr variable. All
others are in expressions used with static_assert.

Includes:
Update mini_chromium to 737433ebade4d446643c6c07daae02a67e8deccao

f701716d9546 Add Windows ARM64 build target to mini_chromium
87a95a3d6ac2 Remove the arraysize macro
1f7255ead1f7 Placate MSVC in areas of base::size usage
737433ebade4 Add cast

Bug: chromium:837308
Change-Id: I6a5162654461b1bdd9b7b6864d0d71a734bcde19
Reviewed-on: https://chromium-review.googlesource.com/c/1396108
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-01-04 22:42:57 +00:00
Vlad Tsyrklevich
bc1b4e833e Update comment to reflect current state
Bug: crashpad:270
Change-Id: I51869f3f613057f617d8f73ca6643bfe2ab75573
Reviewed-on: https://chromium-review.googlesource.com/c/1394154
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2019-01-03 21:23:27 +00:00
Vlad Tsyrklevich
e5ff36fb95 Use CrashpadInfoReader in ModuleSnapshotWin
In preparation for deleting the custom CrashpadInfo reading routines in
the PEImageReader and also deleting the PEImageAnnotationsReader, this
change moves ModuleSnapshotWin to using the platform-independent
CrashpadInfoReader.

Bug: crashpad:270
Change-Id: Idad5de173200068243eacb2bb11b2d95b6438e90
Reviewed-on: https://chromium-review.googlesource.com/c/1388017
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-01-03 19:53:36 +00:00
Avi Drissman
c8a016b99d Remove base's arraysize from Crashpad.
BUG=837308
R=mark@chromium.org

Change-Id: Ibecbfc7bc2d61ee54bc1114e4b20978adbc77db2
Reviewed-on: https://chromium-review.googlesource.com/c/1393921
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
2019-01-03 19:44:15 +00:00
David Bienvenu
bcce074143 Make crashpad support either PSAPI_VERSION 1 or 2
Bug: 584969
Change-Id: I03913e8987a576154b29cac18e95c14d121c9762
Reviewed-on: https://chromium-review.googlesource.com/c/1393605
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-01-03 03:34:22 +00:00
Vlad Tsyrklevich
760da9b96a Delete snapshot/api/module_annotations_win*
This API was added for Kasko several years ago but that project is
defunct and this API does not appear to be used elsewhere.

Bug: crashpad:270
Change-Id: I5a409deff7c5cf4f9f552893d4a49303f3000164
Reviewed-on: https://chromium-review.googlesource.com/c/1388022
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-21 19:19:24 +00:00
Vlad Tsyrklevich
cc60f9329e Refactor PEImageAnnotationsReader test
In preparation for deleting the PEImageAnnotationsReader (and replacing
it with the generic ImageAnnotationsReader) change the
PEImageAnnotationsReader test to be a ModuleSnapshotWin test instead.
The tests are still useful for testing the annotations on the module
snapshot.

Bug: crashpad:270
Change-Id: Ibbbc69c72ca2eb98bfae9dc9b57bf28e9d3f12e2
Reviewed-on: https://chromium-review.googlesource.com/c/1388018
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-21 15:50:44 +00:00
Vlad Tsyrklevich
fccd9c09c0 Implement ProcessSnapshotMac::Memory()
Plumb ProcessReaderMac::Memory() through to ProcessSnapshotMac::Memory()
and add consts where necessary to accomodate the type signature of
ProcessSnapshot::Memory().

Bug: crashpad:263
Change-Id: I2608979918bc201ae3561483ea52ed2092cbc1e2
Reviewed-on: https://chromium-review.googlesource.com/c/1387924
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-20 22:01:27 +00:00
Vlad Tsyrklevich
3b9e3aad1b Move and rename TaskMemory to ProcessMemoryMac
Bug: crashpad:263
Change-Id: I5efa4fe26f09c8b8a8db6dbcedc416724404b894
Reviewed-on: https://chromium-review.googlesource.com/c/1387884
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-12-20 21:35:37 +00:00
Vlad Tsyrklevich
bf6d2e0283 Refactor TaskMemory initialization
Currently, TaskMemory implements the ProcessMemory interface almost
exactly; however, it's initialized using a constructor instead of an
Initialize method which makes it incompatible with a number of
ProcessMemory tests. Change its initialization to match the other
ProcessMemory classes.

Bug: crashpad:263
Change-Id: I8022dc3e1827a5bb398aace0058ce9494b6b6eb6
Reviewed-on: https://chromium-review.googlesource.com/c/1384447
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-12-19 23:28:10 +00:00
Joshua Peraza
2afe6dc210 android/linux: Support modules with shared relros on Android
Add MemoryMap::Iterator to support different strategies for locating
the start of module mappings on Android and Linux.

Beginning with API 21, Bionic provides android_dlopen_ext() which
allows passing a file descriptor with an existing relro segment to the
loader. This means that the mapping containing the dynamic segment
could have a name, device, and inode which are different than the
other mappings for the module.

The revised strategy for Android at API 21+ is to search all mappings
in reverse order from they dynamic array mapping until a module is
parsed with the expected dynamic array address.

Linux and Android 20- continue to select mappings using the device,
inode, and file offsets of the mappings.

Bug: crashpad:268
Change-Id: I30e95e51cb6874c00875d2a9c57f1249877736d4
Reviewed-on: https://chromium-review.googlesource.com/c/1374375
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-12-17 22:58:16 +00:00
Scott Graham
8b6f158d20 fuchsia: Include address space information in process snapshot
This plumbs some of the ZX_INFO_PROCESS_MAPS information out into
MINIDUMP_MEMORY_INFO. The mapping loses some information that Zircon
provides, and some of the data that Windows would provide isn't
available (for example, AllocationProtect). But this gives a general
idea of the memory layout of the process to check for bad pointers, etc.
when inspecting crashes.

Bug: fuchsia:DX-615
Change-Id: I2d7c02be0996672253cf0b1eb6a60b0a55e6033b
Reviewed-on: https://chromium-review.googlesource.com/c/1377089
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-12-14 21:39:06 +00:00
Tom Tan
761c6fe8be Add Windows ARM64 support to Chromium crashpad
Bug: chromium:893460
Change-Id: Ifbeb6f937a6b96c77b02dcf8afe492c5bc617435
Reviewed-on: https://chromium-review.googlesource.com/c/1347773
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-12-12 21:54:55 +00:00
Francois Rousseau
c56557ae4a [fuchsia][arm64][snapshot] remove NOTREACHEDs
we now run this code on arm64 devices in debug mode

Bug: crashpad:196
Bug: fuchsia:DX-712
Change-Id: Iea1975c5bd4cab3d503ca371ab731e25962fb255
Tested: /system/test/crashpad_tests on arm64 device in debug mode
Reviewed-on: https://chromium-review.googlesource.com/c/1352097
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-11-27 19:18:02 +00:00
Vlad Tsyrklevich
083fd52cc3 linux: Fix build failure on ARM/MIPS
Add const to ProcessMemory pointers from ProcessReaderLinux::Memory().
This code is ifdef'd to only build on ARM/MIPS.

Change-Id: I93983a83d06bd5bd338b93babdb326fa94925c53
Reviewed-on: https://chromium-review.googlesource.com/c/1341228
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-11-17 16:54:00 +00:00
Vlad Tsyrklevich
f42a579b8c Add ProcessSnapshotMinidump::CustomMinidumpStreams()
Add a method to ProcessSnapshotMinidump to expose a similar interface
to ModuleSnapshot::CustomMinidumpStreams(). It's implemented on the
process snapshot here because there is no way to map custom minidump
streams back to a specific module. This allows implementing tests that
inspect custom user streams in minidumps.

Bug: 896019

Change-Id: I1673c342753e13d64bddcc0083ca29fa356deac7
Reviewed-on: https://chromium-review.googlesource.com/c/1271405
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-17 05:01:50 +00:00
Vlad Tsyrklevich
1c4c1277e8 Add a ProcessSnapshot::Memory method
Add a method to the ProcessSnapshot to expose a ProcessMemory object to
allow reading memory directly from the underlying process.

CQ-DEPEND=CL:1278830

BUG=crashpad:262

Change-Id: Ied2a5510a9b051c7ac8c41cdd060e8daa531086e
Reviewed-on: https://chromium-review.googlesource.com/c/1315428
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-14 19:13:39 +00:00
Vlad Tsyrklevich
656fa55c74 Refactor ProcessReaderWin to use ProcessMemoryWin
Remove ProcessReaderWin's ReadMemory() and ReadAvailableMemory() methods
and replace their uses with a new method that exposes an instance of
ProcessMemoryWin instead.

BUG=crashpad:262

Change-Id: Ief5b660b0504d7a740ee53c7cd2fa7672ae56249
Reviewed-on: https://chromium-review.googlesource.com/c/1278830
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-11-14 18:38:46 +00:00
Scott Graham
fdc1883a13 fuchsia: Disable ProcessReaderFuchsia.ChildThreads, flaking
Flaking like:

[ RUN ] ProcessReaderFuchsia.ChildThreads
[22244:22258:20181109,001621.809627:ERROR scoped_task_suspend.cc:44] thread failed to suspend
[22244:22258:20181109,001621.810893:WARNING process_reader_fuchsia.cc:283] zx_thread_read_state(ZX_THREAD_STATE_GENERAL_REGS): ZX_ERR_BAD_STATE (-20)
[22244:22258:20181109,001621.810937:WARNING process_reader_fuchsia.cc:295] zx_thread_read_state(ZX_THREAD_STATE_VECTOR_REGS): ZX_ERR_BAD_STATE (-20)
../../third_party/crashpad/snapshot/fuchsia/process_reader_fuchsia_test.cc:161: Failure
Expected: (threads[i].stack_regions.size()) > (0u), actual: 0 vs 0
[ FAILED ] ProcessReaderFuchsia.ChildThreads (2487 ms)

ScopedTaskSuspend appears to try relatively hard to suspend, and without
retrying indefinitely it's not clear how to do a better job. Retrying
forever isn't suitable for production code though, where it would cause
the crash reporter to hang.

Bug: fuchsia:US-553
Change-Id: Ie233d2f5578cb8c35ce47207df4f1f8d2e1152f1
Reviewed-on: https://chromium-review.googlesource.com/c/1328022
Reviewed-by: Francois Rousseau <frousseau@google.com>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-11-09 16:10:50 +00:00
Francois Rousseau
71c75401c4 Revert "[fuchsia] re-introduce pstate temporarily"
This reverts commit 7f71c57a29cd9cfa719eb7730d8984aaef4adc05.

Reason for revert: Fuchsia has been transitioned to spsr.

Original change's description:
> [fuchsia] re-introduce pstate temporarily
> 
> https://fuchsia.googlesource.com/garnet/+/master/bin/zxdb/client/minidump_remote_api.cc#127
> still depends on pstate and we cannot run CQ for hard transitions in Fuchsia yet
> 
> Change-Id: Iea2bfc670871a8fe3f389cc54627733e6069ecbe
> Reviewed-on: https://chromium-review.googlesource.com/c/1318067
> Reviewed-by: Scott Graham <scottmg@chromium.org>
> Commit-Queue: Francois Rousseau <frousseau@google.com>

TBR=scottmg@chromium.org,frousseau@google.com

Change-Id: I5a13cab9a11b6c1262d6832e2dd5b09cad5b3740
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/1321269
Reviewed-by: Francois Rousseau <frousseau@google.com>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2018-11-06 22:11:58 +00:00
Joshua Peraza
3663b7cbbe Reland "Use a relative address in .note.crashpad.info"
This is a reland of 95e97a32eba4d505ab9591e683d2147c441eea48

Original change's description:
> Use a relative address in .note.crashpad.info
> 
> The desc value in the note is now the offset of CRASHPAD_INFO_SYMBOL
> from desc.
> 
> Making this note writable can trigger a linker error resulting in
> the binary embedding .note.crashpad.info to be rejected by the
> kernel during program loading.
> 
> The error was observed with:
> GNU ld (GNU Binutils for Debian) 2.30
> clang version 4.0.1-10 (tags/RELEASE_401/final)
> Debian 4.17.17-1rodete2
> 
> When the note is made writable, crashpad_snapshot_test contains two
> PT_LOAD segments which map to the same page.
> 
> LOAD         0x0000000000000000 0x0000000000000000 0x0000000000000000
>              0x0000000000000258 0x0000000000000258  R      0x200000
> LOAD         0x0000000000000258 0x0000000000000258 0x0000000000000258
>              0x00000000002b84d8 0x00000000002b8950  RWE    0x200000
> 
> Executing this binary with the execv system call triggers a segfault
> during program loading (an error can't be returned because the original
> process vm has already been discarded).
> 
> I suspect (I haven't set up a debuggable kernel) the failure occurs
> while attempting to map the second load segment because its virtual
> address, 0x258, is in the same page as the first load segment.
> https://elixir.bootlin.com/linux/v4.17.17/source/fs/binfmt_elf.c#L380
> 
> The linker normally produces consecutive load segments where the second
> segment is loaded 0x200000 bytes after the first, which I think is the
> maximum expected page size. Modifying the test executable to load the
> second segment at 0x1258 (4096 byte page size) allows program loading
> to succeed (but of course crashes after control is given to it).
> 
> Bug: crashpad:260
> Change-Id: I2b9f1e66e98919138baef3da991a9710bd970dc4
> Reviewed-on: https://chromium-review.googlesource.com/c/1292232
> Reviewed-by: Scott Graham <scottmg@chromium.org>
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Commit-Queue: Joshua Peraza <jperaza@chromium.org>

Bug: crashpad:260
Change-Id: I66713de84cc26c9119e0454d19c9c189263fe054
Reviewed-on: https://chromium-review.googlesource.com/c/1318066
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-11-06 21:38:33 +00:00
Francois Rousseau
7f71c57a29 [fuchsia] re-introduce pstate temporarily
https://fuchsia.googlesource.com/garnet/+/master/bin/zxdb/client/minidump_remote_api.cc#127
still depends on pstate and we cannot run CQ for hard transitions in Fuchsia yet

Change-Id: Iea2bfc670871a8fe3f389cc54627733e6069ecbe
Reviewed-on: https://chromium-review.googlesource.com/c/1318067
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2018-11-05 23:14:23 +00:00
Mark Mentovai
131dd81d4c mac: Fix crashpad_snapshot_test ProcessReaderMac.Child*Thread* for 10.14
pthread_threadid_np() reports an incorrect thread ID after fork() on
macOS 10.14 (“Mojave”). See https://openradar.appspot.com/43843552. As a
workaround, use thread_info(…, THREAD_IDENTIFIER_INFO, …).

This uses MachThreadSelf(), which in turn uses pthread_mach_thread_np(),
which does not suffer from the same bug. As an alternative,
base::mac::ScopedMachSendRight(mach_thread_self()) could be used.

Bug: crashpad:249
Change-Id: I757d6e94236cff533b9c1326f028110b6d214ee5
Reviewed-on: https://chromium-review.googlesource.com/c/1318271
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-11-05 20:06:15 +00:00
Vlad Tsyrklevich
1b20b620cf Fix 32-bit Windows downcast build failure
Bug: crashpad:264
Change-Id: Ie185fbe6fe909568b7364496586fb950c074674f
Reviewed-on: https://chromium-review.googlesource.com/c/1318378
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-11-05 19:40:08 +00:00
Scott Graham
9ee48fb1be Revert "Use a relative address in .note.crashpad.info"
This reverts commit 95e97a32eba4d505ab9591e683d2147c441eea48.

Reason for revert: arm64 lto build

Original change's description:
> Use a relative address in .note.crashpad.info
> 
> The desc value in the note is now the offset of CRASHPAD_INFO_SYMBOL
> from desc.
> 
> Making this note writable can trigger a linker error resulting in
> the binary embedding .note.crashpad.info to be rejected by the
> kernel during program loading.
> 
> The error was observed with:
> GNU ld (GNU Binutils for Debian) 2.30
> clang version 4.0.1-10 (tags/RELEASE_401/final)
> Debian 4.17.17-1rodete2
> 
> When the note is made writable, crashpad_snapshot_test contains two
> PT_LOAD segments which map to the same page.
> 
> LOAD         0x0000000000000000 0x0000000000000000 0x0000000000000000
>              0x0000000000000258 0x0000000000000258  R      0x200000
> LOAD         0x0000000000000258 0x0000000000000258 0x0000000000000258
>              0x00000000002b84d8 0x00000000002b8950  RWE    0x200000
> 
> Executing this binary with the execv system call triggers a segfault
> during program loading (an error can't be returned because the original
> process vm has already been discarded).
> 
> I suspect (I haven't set up a debuggable kernel) the failure occurs
> while attempting to map the second load segment because its virtual
> address, 0x258, is in the same page as the first load segment.
> https://elixir.bootlin.com/linux/v4.17.17/source/fs/binfmt_elf.c#L380
> 
> The linker normally produces consecutive load segments where the second
> segment is loaded 0x200000 bytes after the first, which I think is the
> maximum expected page size. Modifying the test executable to load the
> second segment at 0x1258 (4096 byte page size) allows program loading
> to succeed (but of course crashes after control is given to it).
> 
> Bug: crashpad:260
> Change-Id: I2b9f1e66e98919138baef3da991a9710bd970dc4
> Reviewed-on: https://chromium-review.googlesource.com/c/1292232
> Reviewed-by: Scott Graham <scottmg@chromium.org>
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Commit-Queue: Joshua Peraza <jperaza@chromium.org>

TBR=scottmg@chromium.org,jperaza@chromium.org,mark@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: crashpad:260
Change-Id: I7a2c741e6b4c10d3e3b8be3213a8ce2cd93675f7
Reviewed-on: https://chromium-review.googlesource.com/c/1316372
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-11-03 03:28:19 +00:00
Joshua Peraza
da3c7e7ac5 android: fix the build
References to mcontext_t's pstate were mistakenly changed to spsr here:
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1312193

Also Android's time_t is a signed type.

Change-Id: I4cf83d57b70dced9360a816e87c30a4aaba778ca
Reviewed-on: https://chromium-review.googlesource.com/c/1315789
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-11-02 22:57:09 +00:00
Joshua Peraza
0b19010fba Include windows.h before dbghelp.h
dbghelp.h requires windows.h to have been included.

Change-Id: I66d40e396d60cafe99c2480fdfbf1a9114abe386
Reviewed-on: https://chromium-review.googlesource.com/c/1315787
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-11-02 18:14:07 +00:00
Francois Rousseau
9d4afb0582 [fuchsia][arm64] support vector registers
Bug: fuchsia:DX-642
Change-Id: I898b75e47d0dd810025db6ea27e2e0e73ec82768
Tested: CQ
Reviewed-on: https://chromium-review.googlesource.com/c/1310513
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-11-01 19:44:15 +00:00
Francois Rousseau
a4754a9ae9 [snapshot][arm64] rename CPU context pstate to spsr
* upon exception, the process state ("pstate") is stored in the saved
process status register ("spsr") so the register we are manipulating is
really just the SPSR
* https://developer.arm.com/products/architecture/cpu-architecture/a-profile/docs/100878/latest/the-saved-process-status-register

Change-Id: I9ce612c00b7a56a0f6d778d974ff9e0e5402ca5e
Reviewed-on: https://chromium-review.googlesource.com/c/1312193
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2018-11-01 18:01:40 +00:00
Francois Rousseau
8c0d3d2c1e [fuchsia] support general registers for arm64
Bug: fuchsia:DX-639
Change-Id: Iaf44fffc6adc11025a37f3a62676cdebff435002
Tested: CQ; `crasher` on Fuchsia device (report id 27fac91e5550ea06)
Reviewed-on: https://chromium-review.googlesource.com/c/1309159
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-11-01 00:03:33 +00:00
Joshua Peraza
95e97a32eb Use a relative address in .note.crashpad.info
The desc value in the note is now the offset of CRASHPAD_INFO_SYMBOL
from desc.

Making this note writable can trigger a linker error resulting in
the binary embedding .note.crashpad.info to be rejected by the
kernel during program loading.

The error was observed with:
GNU ld (GNU Binutils for Debian) 2.30
clang version 4.0.1-10 (tags/RELEASE_401/final)
Debian 4.17.17-1rodete2

When the note is made writable, crashpad_snapshot_test contains two
PT_LOAD segments which map to the same page.

LOAD         0x0000000000000000 0x0000000000000000 0x0000000000000000
             0x0000000000000258 0x0000000000000258  R      0x200000
LOAD         0x0000000000000258 0x0000000000000258 0x0000000000000258
             0x00000000002b84d8 0x00000000002b8950  RWE    0x200000

Executing this binary with the execv system call triggers a segfault
during program loading (an error can't be returned because the original
process vm has already been discarded).

I suspect (I haven't set up a debuggable kernel) the failure occurs
while attempting to map the second load segment because its virtual
address, 0x258, is in the same page as the first load segment.
https://elixir.bootlin.com/linux/v4.17.17/source/fs/binfmt_elf.c#L380

The linker normally produces consecutive load segments where the second
segment is loaded 0x200000 bytes after the first, which I think is the
maximum expected page size. Modifying the test executable to load the
second segment at 0x1258 (4096 byte page size) allows program loading
to succeed (but of course crashes after control is given to it).

Bug: crashpad:260
Change-Id: I2b9f1e66e98919138baef3da991a9710bd970dc4
Reviewed-on: https://chromium-review.googlesource.com/c/1292232
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-10-31 23:35:50 +00:00
Casey Dahlin
df5d1aa3ff Implement Stack() for ThreadSnapshotMinidump
We also remove the NOTREACHED guard from ExtraMemory and just let it
return nothing (see comment for rationale). This should be the last of
the methods in ThreadSnapshotMinidump.

Bug: crashpad:10
Change-Id: If7148d3ead1ae5887da300131efc8a078b350b54
Reviewed-on: https://chromium-review.googlesource.com/c/1296806
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Casey Dahlin <sadmac@google.com>
2018-10-24 23:38:12 +00:00
Casey Dahlin
411f0ae41d Implement MemoryMap for ProcessSnapshotMinidump
Bug: crashpad:10
Change-Id: Icca05321b729fd869a371707940fab40e12e8e22
Reviewed-on: https://chromium-review.googlesource.com/c/1294254
Commit-Queue: Casey Dahlin <sadmac@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-10-23 20:28:53 +00:00
Casey Dahlin
95b177e793 Flesh out ModuleSnapshotMinidump
Most of the methods are implemented now. Only a couple stragglers left.

Bug: crashpad:10
Change-Id: Ib0d2f7571d9a0e7bab1a24c66355c05804b63367
Reviewed-on: https://chromium-review.googlesource.com/c/1290171
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Casey Dahlin <sadmac@google.com>
2018-10-19 21:12:38 +00:00
Casey Dahlin
456476c3f6 Add ReadMinidumpUTF16String
Change-Id: If0f33e39bad29ade28eaab8dc064318253e7e70e
Reviewed-on: https://chromium-review.googlesource.com/c/1290170
Commit-Queue: Casey Dahlin <sadmac@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-10-19 20:58:00 +00:00
Casey Dahlin
8d17d5b4cf Decode Thread Context in minidump
We can now get the CPU state for threads from minidump snapshots.

Bug: crashpad:10
Change-Id: I6bef2b033f7b04fcfa64c114be94064f3e0ae775
Reviewed-on: https://chromium-review.googlesource.com/c/1285034
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-10-17 22:44:04 +00:00
Casey Dahlin
b6103e157c Add SystemSnapshotMinidump
Only partially implemented, but we can get most of the useful stuff,
including CPU Architecture.

Bug: crashpad:10
Change-Id: I727eeef5770430253a45cd046a66488f743ac25a
Reviewed-on: https://chromium-review.googlesource.com/c/1285033
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-10-17 17:34:11 +00:00
Casey Dahlin
7682f0f6eb Add ThreadSnapshotMinidump
Only partially implemented, but ProcessSnapshotMinidump now returns them
appropriately.

Bug: crashpad:10
Change-Id: I44f598256965e404f62bd93e9e2efc61527298db
Reviewed-on: https://chromium-review.googlesource.com/c/1278280
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-10-12 21:25:14 +00:00
Joshua Peraza
9b2a119dc6 elf: don't warn on trailing unread bytes in the elf dynamic array
This warning triggers reliably on most binaries and on android, spams
the logcat which may obfuscate other errors.

The actual amount varies, but is typically 40 bytes for 32-bit android
system libraries, 80 bytes for 64-bit android system libraries,
64 bytes for linux system libraries (on my machine), but so far they're
all zeroes.

Change-Id: I658434e8290c75641a3b17034ebdd958834bcd69
Reviewed-on: https://chromium-review.googlesource.com/c/1269740
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-10-09 03:08:58 +00:00
Joshua Peraza
688dcfa22e android: handle modules loaded from zipfiles
Modules mapped from zipfiles will have mappings named for the zipfile
rather than the module name and an offset into that zipfile instead of
0.

Bug: crashpad:253, crashpad:254
Change-Id: I0503d13e7b80ba7bd1cc2d241633d9c68c98f1cd
Reviewed-on: https://chromium-review.googlesource.com/1232294
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-09-20 17:42:56 +00:00
Joshua Peraza
8595f4b423 linux: allow collecting scheduler priorities to fail
SELinux blocks the handler from collecting these values on Android M.
They should eventually be collected via the broker.

Change-Id: Iad47759b2ebf23148cb5b2c401241ee87f8ffd27
Reviewed-on: https://chromium-review.googlesource.com/1226120
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-09-14 16:53:29 +00:00
Joshua Peraza
b918119ca2 linux: Read thread IDs via a PtraceConnection
Bug: crashpad:250
Change-Id: I2ff9c2d810f7af25f7438e974e0adfb5abebec16
Reviewed-on: https://chromium-review.googlesource.com/1200962
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-09-12 00:39:03 +00:00
Joshua Peraza
78bf924fa6 linux: Read /proc/<pid> files via PtraceConnection
Bug: crashpad:250
Change-Id: I93c8944c48a17bd2c2b34cd9b8d81750cf80229c
Reviewed-on: https://chromium-review.googlesource.com/1200311
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-09-10 16:20:12 +00:00
Wez
bc50af15a2 Migrate from ScopedZxHandle to libzx containers.
Bug: chromium:852541
Change-Id: Ie05c70f249e6f843183a02ec61fd09f6a0607598
Reviewed-on: https://chromium-review.googlesource.com/1148923
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
2018-08-01 17:38:19 +00:00
Joshua Peraza
52ff1accbb linux: Fix locating modules with multiple mappings from offset 0
The general strategy used by Crashpad to determine loaded modules is to
read the link_map to get the addresses of the dynamic arrays for all
loaded modules. Those addresses can then be used to query the MemoryMap
to locate the module's mappings, and in particular the base mapping
from which Crashpad can parse the entire loaded ELF file.

ELF modules are typically loaded in several mappings with varying
permissions for different segments. The previous strategy used to find
the base mapping for a module was to search backwards from the mapping
for the dynamic array until a mapping from file offset 0 was found for
the same file. This fails when the file is mapped multiple times from
file offset 0, which can happen if the first page of the file contains
a GNU_RELRO segment.

This new strategy queries the MemoryMap for ALL mappings associated
with the dynamic array's mapping, mapped from offset 0. The consumer
(process_reader_linux.cc) can then determine which mapping is the
correct base by attempting to parse a module at that address and
corroborating the PT_DYNAMIC or program header table address from the
parsed module with the values Crashpad gets from the link_map or
auxiliary vector.

Bug: crashpad:30
Change-Id: Ibfcbba512e8fccc8c65afef734ea5640b71e9f70
Reviewed-on: https://chromium-review.googlesource.com/1139396
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-07-26 15:33:15 +00:00
Joshua Peraza
0909bee2e2 linux: Fix broken tests with address sanitizer
These fixes are mostly related to address sanitizer causing stack
variables to not be stored on the call-stack. Attempting to disable
safe-stack has no effect.

Change-Id: Ib5718bfb74ce91dee560b397ccdbf68d78e4ec6a
Reviewed-on: https://chromium-review.googlesource.com/1140507
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-07-24 19:52:58 +00:00
Joshua Peraza
c11c8833f7 Add ProcessSnapshotMinidump::ProcessID()
Bug: crashpad:30, crashpad:10
Change-Id: I7013debfc9b68ef218c48f859ffdcf7051ea43d9
Reviewed-on: https://chromium-review.googlesource.com/1148540
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-07-24 16:44:58 +00:00
Mark Mentovai
03abd1bb34 mac: Tolerate the new flavor of weird cl_kernels modules on 10.14
OpenCL modules that appeared as “cl_kernels” since 10.7 now show up in
10.14 as ad-hoc signed modules at
/private/var/db/CVMS/cvmsCodeSignObjXXXXXXXXXXXXXXXX (16 random
characters). The modules are unlinked from the filesystem once loaded.

Bug: crashpad:243
Change-Id: I00fdd1311d4e6cd4c9224ef54ac990ac1afb849c
Reviewed-on: https://chromium-review.googlesource.com/1142027
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-07-18 17:28:49 +00:00
Djordje Golubovic
cb41ba7471 Added MIPS support to crashpad.
Modified gyp/gn files to support MIPS targets.

Implemented thread_info, cpu_context, signal context classes for MIPS target.

Addressed MIPS specific signal ordering.

Added "MIPS Technologies, Inc." to AUTHORS file.

Bug: crashpad:232
Change-Id: Ibfc221ba54088e95f984b9dc6be5fd52f86abcc2
Reviewed-on: https://chromium-review.googlesource.com/1064594
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-07-10 15:29:34 +00:00
Nick Maniscalco
aabc485b64 fuchsia: Use ZX_TIME_INFINITE instead of UINT64_MAX
In the future, Zircon's time types will change from unsigned to
signed. Use ZX_TIME_INFINITE instead of UINT64_MAX when
zx_nanosleep'ing.

See related Zircon bug ZX-2100.

Change-Id: I5eb139280c27ca817e1a489f04c860563c9b677c
Reviewed-on: https://chromium-review.googlesource.com/1123221
Commit-Queue: Nick Maniscalco <maniscalco@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-07-02 22:40:38 +00:00
Joshua Peraza
b169295702 linux: include missing ucontext header
Change-Id: Icac41faf501bba63b3bcd0cdc41e8fa26ca3509c
Reviewed-on: https://chromium-review.googlesource.com/1117371
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-06-27 20:25:29 +00:00
Jose Dapena Paz
4b05be4265 linux: fix ARM snapshot context traits build.
On GCC with libstdc++, ContextTraits fail to build because of the missing
declaration of offsetof (should include cstddef) and for aliasing a type
with the same name overriding previous declaration.

Change-Id: Ic497238122bcb430f14f9234644c483a8e27e3b6
Reviewed-on: https://chromium-review.googlesource.com/1114606
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: José Dapena Paz <jose.dapena@lge.com>
2018-06-26 17:33:05 +00:00
Scott Graham
7c6d2334a9 Don't fail minidump write if memory snapshot read fails
On Windows (and probably elsewhere) it's possible that something else on
the system changes the memory map between when a memory snapshot range
is added to the minidump, and when the process's memory is actually read
from the target and written to the .dmp file. As a result, failing the
Read() should not result in aborting the minidump's write, which it
previously would have.

Bug: crashpad:234
Change-Id: Ib24e255a34fa2e1758621d3955ebc7a0f96166e2
Reviewed-on: https://chromium-review.googlesource.com/1096452
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-06-12 17:46:22 +00:00
Joshua Peraza
d1e6a2130d android/linux: add a client interface to control sanitization
Sanitization is controlled by a SanitizationInformation struct to be
read from the client's memory. The address of this struct is either
passed in a ClientInformation when the client requests a crash dump,
or as a flag to the handler --sanitization_information.

Bug: crashpad:30
Change-Id: I2744f8fb85b4fea7362b2b88faa4bef1da74e36b
Reviewed-on: https://chromium-review.googlesource.com/1083143
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-06-12 15:37:11 +00:00
Joshua Peraza
a42b5269b4 Add ProcessSnapshotSanitized
A ProcessSnapshotSanitized enables filtering possibly sensitive
information from a snapshot.

WebView has different privacy constraints than Chrome and needs to
avoid collecting data in annotations or from stack memory that may
contain PII. This CL enables:

1. Filtering annotations by name using a whitelist.
2. Filtering for crashes which reference a particular module.
3. Redacting non-essential information from stack memory.

This CL does not provide a client interface to enable sanitization.

Bug: crashpad:30
Change-Id: I8944c70fdcca6d6d4b7955d983320909bf871254
Reviewed-on: https://chromium-review.googlesource.com/1070472
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-06-11 16:46:29 +00:00
Scott Graham
9a97daff39 Add libfuzzer support
Adds the build support for using libfuzzer controlled by setting
`crashpad_use_libfuzzer=true`.

Also adds a first fuzzer (for ElfImageReader). Currently only runs on
Linux, but should work on Fuchsia too with some minor fixes (not sure
yet whether the fixes required are toolchain or in our build setup).

Run as:
  out/lin/elf_image_reader_fuzzer snapshot/elf/elf_image_reader_fuzzer_corpus/
hits an OOM pretty quickly in trying to allocate a giant buffer.

Bug: crashpad:30, crashpad:196, crashpad:233
Change-Id: Idd3ca11fe00319b8b29e029d5e13b17bfd518ea0
Reviewed-on: https://chromium-review.googlesource.com/1083451
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-06-07 21:09:53 +00:00
Scott Graham
5191992ae5 win: Fix SimulateCrash.ChildDumpWithoutCrashing under ASAN, disable others
SimulateCrash.ChildDumpWithoutCrashing needed a larger threshold due to
ASAN instrumentation.

These tests expect children to crash, but ASAN captures the exception
before letting Crashpad handle it:

CrashpadClient.HandlerLaunchFailureCrash
CrashpadClient.HandlerLaunchFailureDumpAndCrash
CrashpadHandler.ExtensibilityCalloutsWork
ExceptionSnapshotWinTest.ChildCrash

(which is an upstreaming of https://chromium-review.googlesource.com/1067151).

Additionally, because Chrome doesn't build all, I noticed a missing
dependency on a test binary which is added here.


Bug: chromium:845011
Change-Id: I5c3ae5673512be29edad21e7d20dd57b8b5ce2bf
Reviewed-on: https://chromium-review.googlesource.com/1075715
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-05-29 17:04:18 +00:00
Adam Barth
3033802ed4 Remove unused port wait/queue argument
Change-Id: Ifcfe6c2d18045ce3a2e443ee84d4dd84bb3db373
Reviewed-on: https://chromium-review.googlesource.com/1073567
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-05-25 16:00:13 +00:00
Joshua Peraza
c86c9f0f73 Don't merge stack mappings with different names
This is particularly a problem when the neighboring mapping is a
special mapping not readable from another process. For example:

7fff96aeb000-7fff96b0c000 rw-p 00000000 00:00 0  [stack]
7fff96b0c000-7fff96b0e000 r--p 00000000 00:00 0  [vvar]

[vvar] is a special mapping which makes some kernel data available
for virtual system calls. Attempting to read this region via the
/proc/<pid>/maps file returns an IO error which causes Crashpad to
abort capturing any of the thread's stack.

Neighboring mappings with empty names are eligible to be merged since
they result from changing permissions on existing named mappings.

Change-Id: I587bd2ec6f9759d284f1f9b1d93f2a44ddf61e92
Reviewed-on: https://chromium-review.googlesource.com/1072803
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-05-25 14:30:33 +00:00
Joshua Peraza
d78bd067c7 linux: Initialize a crashing thread's stack from its exception context
Bug: crashpad:30
Change-Id: I6b9927d391006f02a3515dbebe954cffaad00598
Reviewed-on: https://chromium-review.googlesource.com/1060031
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-05-15 18:10:54 +00:00
Scott Graham
cc1573cd52 fuchsia: Fix compile error after 19e6087bb
Bug: crashpad:196
Change-Id: I82cf1c5384ebfc2fb7882e69145b211c4b24f7c5
Reviewed-on: https://chromium-review.googlesource.com/1054576
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-05-11 00:39:17 +00:00
Joshua Peraza
19e6087bb2 Don't restrict ImageAnnotationReader to a module's address range
Annotations data structures may be dynamically allocated so could
appear outside a modules's address range. Let ImageAnnotationReader
use a ProcessMemoryRange for the process, rather than the module.

Also add a test for linux.

Bug: crashpad:30
Change-Id: Ibbf1d2fcb2e44b1b70c8a02e86c6f2fbd784535f
Reviewed-on: https://chromium-review.googlesource.com/1054705
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-05-11 00:22:06 +00:00
Scott Graham
f55a8d4ff3 fuchsia: Work around lack of packaging in Fuchsia tree build
Packaged test running seems to be a ways off, but with a bit of path
fiddling in test_paths.cc we can actually use the paths where the tests
are copied, so do that instead to get all the tests re-enabled. The
setup in BUILD.gn should be mostly-useful once packaging is working as
all helper/data files will need to specified there anyway.

Also, attempted fix to flaky behaviour in
ProcessReaderFuchsia.ChildThreads exposed because the tests are now
being run. zx_object_wait_many() waits on *any* of the objects, not
*all* of them. Derp!

And finally, for the same test, work around some unintuitive behaviour
in zx_task_suspend(), in particular that the thread will not be
suspended for the purpose of reading registers right away, but instead
only "sometime later", which appears in pratice to be after the next
context switch. Have ScopedTaskSuspend block for a while to try to
ensure the registers become readble, and if they don't, at least fail
noisily at that point.

Bug: crashpad:196
Change-Id: I01fb3590ede96301c941c2a88eba47fdbfe74ea7
Reviewed-on: https://chromium-review.googlesource.com/1053797
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-05-10 19:28:10 +00:00
Scott Graham
31703a585f fuchsia: When in Fuchsia tree, disable tests requiring external files
The package deployment/running is in flux at the moment. In order to get
all the other tests on to the main Fuchsia waterfall, disable the ~25
tests that require external files (for launching child processes,
loading modules, or data files) because those operations all fail on
Fuchsia-without-packages right now. Upstream this is PKG-46. Once test
packaging and running has been resolved, this can be reverted.

These tests are still run when building Crashpad standalone on Fuchsia
as the standalone build simply copies all the relevant data files to the
device in /tmp.

Bug: crashpad:196
Change-Id: I1677c394a2b9d709c59363ebeea8aff193d4c21d
Reviewed-on: https://chromium-review.googlesource.com/1045547
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-05-05 00:27:22 +00:00
Scott Graham
02adab2e80 fuchsia: InitializeException, and write dump in exception handler
Implements InitializeException() in ProcessSnapshot, and pulls it all
together writing the dump in crash handler. Sample output at crash
00163eff624e653e on the staging server.

Also adds a child-retrieve helper to koid_utilities.

Bug: crashpad:196
Change-Id: I4bee7655e81e3243ac0ae896ff0caea7ce4acdad
Reviewed-on: https://chromium-review.googlesource.com/1044771
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-05-05 00:21:22 +00:00
Scott Graham
e78789b9e0 fuchsia: Add implementation of ExceptionSnapshot
Bug: crashpad:196
Change-Id: I5aea3484c185096898bafe847c83474a91f5d8c7
Reviewed-on: https://chromium-review.googlesource.com/1038128
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-05-03 20:35:33 +00:00
Scott Graham
bce68d7975 fuchsia: Miscellaneous fixes to get symbol resolution working
- Endian-swaps the 3 integer fields of the build id when returning it
  for use as the module id (see bug 229).
- Removes the "app:" prefix on the main binary, as this prevents the
  crash server from matching the binary name (and it isn't particularly
  useful anyway)
- Map "<vDSO>" to "libzircon.so" as that's what it actually is, so that
  symbols for it can be found.

Bug: crashpad:196, crashpad:229
Change-Id: Ie4abc732b7696345b96c34dbb1a7d2cc2cfcf77f
Reviewed-on: https://chromium-review.googlesource.com/1035461
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-04-30 21:02:08 +00:00
Scott Graham
a107b8b95d fuchsia: Identify and include stack mapping in dump
Bug: crashpad:196
Change-Id: I4d71502028ba1d961e53c0450c3ae88c6285f04e
Reviewed-on: https://chromium-review.googlesource.com/1033358
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-04-30 20:00:58 +00:00
Scott Graham
63d331e57a fuchsia: Fix child process reader test to do what it should be doing
This "child" test was actually reading itself (whoops!). Instead, pass
the address of the string to be read back from the child and read that.

Bug: crashpad:196
Change-Id: I27aa4cd06c69cd492cb3387a5a773a56e9cb02a3
Reviewed-on: https://chromium-review.googlesource.com/1033712
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-04-27 22:18:19 +00:00
Takuto Ikuta
d4533dc92b Add override for overridden function
Bug: 428099
Change-Id: If8818d02fd6315ad46d512357db2b70d011a52b0
Reviewed-on: https://chromium-review.googlesource.com/1031992
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-04-27 05:48:31 +00:00
Scott Graham
799dcef4c9 fuchsia: Fix compilation after hasty review changes
I'm a dope. I really need to get the trybots enabled again,
but unfortunately I haven't made any useful progress on
https://bugs.chromium.org/p/crashpad/issues/detail?id=219.

Bug: crashpad:196
Change-Id: Iba2a2460d36c17d8261f82deb6cabaab5995111b
Reviewed-on: https://chromium-review.googlesource.com/1012464
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-04-13 19:10:50 +00:00
Scott Graham
c2583364a3 fuchsia: Capture general purpose registers in thread snapshot
Conversion to CPUContext is currently only implemented for x64.

Bug: crashpad:196
Change-Id: I3fb8541f70a6f8d6f12c02e6b17c78e07e195056
Reviewed-on: https://chromium-review.googlesource.com/1007967
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-04-13 17:00:40 +00:00
Scott Graham
f5d5a41317 fuchsia: Add implementation of ScopedTaskSuspend
This implementation has some limitations as documented in the header,
however, threads must be suspended in order to use the register capture
debug API so this is somewhat useful for now in the context of
generate_dump.

Also, refactor some child-object retrieval helpers used in a few places.

Bug: crashpad:196
Change-Id: I1fdae5fc3d4b43841e535724eac10c1e58af04c5
Reviewed-on: https://chromium-review.googlesource.com/1007966
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-04-13 16:46:40 +00:00
Joshua Peraza
c80bf96001 Don't record reports as complete if there is no upload thread
This allows clients to use the database to handle uploads themselves,
e.g. on Android, where Crashpad does not yet provide an uploader.

The handler does not launch an upload thread when no url is supplied.
Previously, the handler would move these reports to
completed and record the upload as skipped with kUploadsDisabled.
With this change, these reports would remain pending until pruned,
with no metrics recorded for them in regard to their upload.

Bug: crashpad:30
Change-Id: I4167ab1531634b10e91d03229018ae6aab4103aa
Reviewed-on: https://chromium-review.googlesource.com/1010970
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-04-13 16:20:01 +00:00
Scott Graham
856339b2d2 fuchsia: Avoid uname() in system snapshot
uname() seems to hang, sometimes, perhaps when then network is in a bad
state. Additionally, this way allows getting a minimal amount of version
information via zx_system_get_version().

Bug: crashpad:196
Change-Id: I2c040ee38ae017a6e8e060de10039bae6d159058
Reviewed-on: https://chromium-review.googlesource.com/1007979
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-04-11 20:48:20 +00:00
Scott Graham
d9bf38f39c fuchsia: More fixes to get a basic minidump written
With this `generate_dump <somepid>` generates a valid and somewhat
plausible (but still quite incomplete) minidump.

As an example, on a running Fuchsia system, `ps` reported the pid of
"netstack" as 6062, followed by `generate_dump 6062`, copy minidump.6062
to host, and run Breakpad's minidump_dump on the generated dump file,
resulting in:
https://gist.github.com/sgraham/24e4ba1af968219d7c154bb0fba43925

This looks roughly correct in that it has a bunch of threads (without
much data) and a reasonable looking module list.

Bug: crashpad:196
Change-Id: I3f68cc015f74374624a5ce497d46ac90df17a22c
Reviewed-on: https://chromium-review.googlesource.com/1005978
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-04-11 04:49:36 +00:00
Scott Graham
a4f4d6a736 fuchsia: Small fixes in system and process snapshot hit on generate_dump
- Implement ProcessID().
- Return empty ProcessStartTime() and ProcessCPUTimes() as there's
  nothing available.
- Return the Threads that were collected in Initialize().
- Return empty MachineDescription() plus upstream bug link.

Bug: crashpad:196
Change-Id: I77b33c18ed3844464bb5b9f238406191c221b17e
Reviewed-on: https://chromium-review.googlesource.com/1005889
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-04-11 02:27:55 +00:00
Scott Graham
f5f0aa4a8e fuchsia: Implementation of system snapshot
Mostly sensible implementation for x64 via cpuid. It's too early for
Fuchsia to have a version number, so nothing is reported for those
fields. ARM64 isn't implemented at all and would hit a lot of
NOTREACHED()s.

Bug: crashpad:196
Change-Id: I6ca8b12e16fe0cf773a17c88ca9d407b028a501c
Reviewed-on: https://chromium-review.googlesource.com/1005906
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-04-10 22:40:45 +00:00
Scott Graham
cf55a7ef55 fuchsia: Implement SnapshotTime()
Bug: crashpad:196
Change-Id: I398a8e933c64fca33e2620543c4c9d52a07f7d8f
Reviewed-on: https://chromium-review.googlesource.com/1005835
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-04-10 21:55:35 +00:00
Joshua Peraza
914e7f76dd linux, x86: Read floating point state via mcontext.fpptr
Floating-point content may not begin at the start of __fpregs_mem and
should be located via mcontext.fpptr, which may be `nullptr`.

Bug: crashpad:30
Change-Id: Ie3116339d79f6669d757618e9e592f8480dcdcba
Reviewed-on: https://chromium-review.googlesource.com/1001332
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-04-09 19:08:13 +00:00
Joshua Peraza
a3ba96c0d4 linux: Use an empty string for unmapped module names
This may be a bug in the target program or loader, but doesn't seem
like something worth dying over. If a link_entry name is empty,
ProcessReaderLinux::InitializeModules() will fall back to using the
name of the module's mapping. In this case, the main executable's
link entry name pointed into unmapped memory, but the memory map was
able to identify it as app_process32.

Bug: crashpad:30
Change-Id: Ic6df08132271efb809bf0bc28f23a333deb20a67
Reviewed-on: https://chromium-review.googlesource.com/999301
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-04-06 02:15:09 +00:00
Joshua Peraza
10fd672bde linux: Enable brokered memory reading
This change:
1. Updates the broker's memory reading protocol to enable short reads.
2. Updates Ptracer to allow short reads.
3. Updates the broker to allow reading from a memory file.
4. Updates the broker's default file root to be "/proc/[pid]/".
5. Adds PtraceConnection::Memory() to produce a suitable memory reader
for a connection type.

Bug: crashpad:30
Change-Id: I8c004016065d981acd1fa74ad1b8e51ce07c7c85
Reviewed-on: https://chromium-review.googlesource.com/991455
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-04-05 22:21:46 +00:00
Fabrice de Gans-Riberi
74a56c256b Prepare for removal of is_posix from the Fuchsia build
This also rolls crashpad/third_party/mini_chromium/mini_chromium/ d42eb4101..6e0fdb2e4 (2 commits)
d42eb41012..6e0fdb2e49

$ git log d42eb4101..6e0fdb2e4 --date=short --no-merges --format='%ad %ae %s'
2018-04-04 scottmg@chromium.org Repair Linux-with-sysroot build after clang update
2018-04-04 fdegans Prepare for |is_posix| switch in the Fuchsia build

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

Bug: chromium:812974
Change-Id: I3d8efc3124c97981eda63f104a7adfb670babab7
Reviewed-on: https://chromium-review.googlesource.com/988231
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-04-04 22:18:25 +00:00
Joshua Peraza
d108fd04a5 linux: Add PtraceConnection::ReadFileContents
Some files, such as /proc/[pid]/maps, may not be accessible to the
handler. This enables the handler access to the contents of those files
via the broker.

This change reads maps and auxv using ReadFileContents.

Bug: crashpad:30
Change-Id: Ia19b498bae473c616ea794ab51c3f22afd5795be
Reviewed-on: https://chromium-review.googlesource.com/989406
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-04-03 22:08:29 +00:00
Joshua Peraza
58e4bbecc2 win, gn: use new lists when using templated targets
The crashpad_{executable, loadable_module} templates won't have
pre-existing configs lists to modify. Use configs and remove_configs
to merge changes into default configs when using the templates.

Change-Id: Id7c0b1991c9d0ac55022b427feb59df28668b959
Reviewed-on: https://chromium-review.googlesource.com/981778
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-03-27 15:35:52 +00:00
Joshua Peraza
5754f608cb android: unset source filters to use linux files
Also disable testing reading AT_ENTRY on Android.

Bug: crashpad:30
Change-Id: I10353bbbb3ff28721a2c05d69463df5eac4df281
Reviewed-on: https://chromium-review.googlesource.com/980811
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-03-27 02:19:39 +00:00
Joshua Peraza
9c89cd99f3 gn: add templates for executables and loadable_modules
When building in chromium, executables and loadable_modules should
depend on:
//build/config:exe_and_shlib_deps
which, among other things, may be needed to introduce a
dependency on a custom libc++.

Bug: crashpad:30
Change-Id: Ic46a3cf5b46bdac09cca22950f9236e0776ba44a
Reviewed-on: https://chromium-review.googlesource.com/974713
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-03-23 16:50:58 +00:00
Joshua Peraza
afd3186280 Roll mini_chromium to d42eb41
Change-Id: I18c0a3cfcc82725f19023aa3d78a937719fd2d49
Reviewed-on: https://chromium-review.googlesource.com/972424
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-03-20 23:00:11 +00:00
Joshua Peraza
cf9e96b856 elf: Use compiler macros in crashpad info size test note
Bug: crashpad:30
Change-Id: If5bdd15dfc050ef57df0e3b59dd6a5e74d4a9b22
Reviewed-on: https://chromium-review.googlesource.com/972367
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-03-20 22:19:23 +00:00
Scott Graham
a45e88602b Skip ELF notes with a p_vaddr of zero
Don't attempt to read data if the note isn't in an allocated segment.
See investigation starting at
https://bugs.chromium.org/p/crashpad/issues/detail?id=220#c27 for
details.

Bug: crashpad:220, crashpad:30, crashpad:196
Change-Id: I60eaacb83ad00ef33bde9079d25cc23a59bdf2c8
Reviewed-on: https://chromium-review.googlesource.com/941507
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-28 21:21:44 +00:00
Scott Graham
fae18c2fc4 fuchsia: Add implementation of ThreadSnapshot
This is mostly empty except for the ID, until I concoct a way to get the
stack out of Fuchsia, and implement context capture.

Bug: crashpad:196
Change-Id: I26d0622d44aefba88750f7ec6feb1a6e95467208
Reviewed-on: https://chromium-review.googlesource.com/932941
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-24 06:14:03 +00:00
Scott Graham
2b05eb522f Rename ProcessReader to platform-suffixed versions
Mac's ProcessReader becomes ProcessReaderMac.
Linux/Android's ProcessReader becomes ProcessReaderLinux.
Fuchsia's ProcessReader becomes ProcessReaderFuchsia.

No intended change in behavior.

Bug: crashpad:196, crashpad:30
Change-Id: I7ec8d72f79533bd78189173261ade2ad99010bad
Reviewed-on: https://chromium-review.googlesource.com/930321
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-22 21:33:39 +00:00
Scott Graham
61f1013ee4 fuchsia: Add some thread reading to ProcessReader and a test
This fills out Threads() in ProcessReader, gathering some information
for which there's system calls, and adds some basic tests for
ProcessReader on Fuchsia.

Bug: crashpad:196
Change-Id: I0738e77121c90a8b883267c1df0fcfc6621674d7
Reviewed-on: https://chromium-review.googlesource.com/929350
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-22 19:10:35 +00:00
Scott Graham
2290a826af Pull (most) platform-specific MemorySnapshots out
Pulls the concrete non-test implementations of MemorySnapshot out into a
template. They were effectively identical on Mac and Linux/Android, and
I was going to have to add another identical one for Fuchsia.
Unfortunately it needs to be a template because of the snapshot merging
template it calls that needs the platform-specific ProcessReader (so it
can't just pass in a base ProcessMemory in initialization instead).

This is used on Mac, Linux, Android, and Fuchsia, but there is still a
Windows implementation (different because its ProcessReader is a bit
different) and a test implementation.

Bug: crashpad:196
Change-Id: I4b5575fee0749e96b08e756be1f8380a2c994d7c
Reviewed-on: https://chromium-review.googlesource.com/929308
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-22 17:35:34 +00:00
Scott Graham
4d96e4e504 fuchsia: Return ModuleSnapshot* out of ProcessSnapshotFuchsia
And document that UnloadedModules() isn't applicable on Fuchsia.

Bug: crashpad:196
Change-Id: Ic2c5f26fbc9cbd908ec0b941797c63f88caeec9c
Reviewed-on: https://chromium-review.googlesource.com/929302
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-21 20:31:33 +00:00
Scott Graham
1aae5cedaf Refactor ModuleSnapshot(Linux|Fuchsia) into ModuleSnapshotElf
They were largely the same after recent changes, so with a bit at
initialization time the whole class can be de-duplicated.

Bug: crashpad:196, crashpad:30
Change-Id: I2f5df797dfe36e120090e570273b48ee03f660a5
Reviewed-on: https://chromium-review.googlesource.com/927611
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-21 20:20:43 +00:00
Scott Graham
cab259330f fuchsia: Pass more data out of module snapshot
After
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/927355
image annotations can be read. Plumb those through
ModuleSnapshotFuchsia.

Bug: crashpad:196
Change-Id: Iba0730fd88c60cbad8a721ddcaf8f60860f76b77
Reviewed-on: https://chromium-review.googlesource.com/927704
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-21 20:02:53 +00:00
Scott Graham
3dd85dc126 fuchsia: Make ImageAnnotationReader[Test] work
Ports the test away from fork() to MultiprocessExec.

Requires a Fuchsia SDK that includes the fix in
https://fuchsia-review.googlesource.com/c/zircon/+/125081.

Bug: crashpad:196, crashpad:215
Change-Id: Ia8d382cebe8d2ffc8d877e5249baf0e58aee248c
Reviewed-on: https://chromium-review.googlesource.com/927355
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-21 02:57:33 +00:00
Scott Graham
d8d03172c2 arm: Capture context around pc and registers
Includes mini_chromium DEPS roll of one change:
4e3b2c0 fuchsia: Make target flag apply to asm too

After this, the Fuchsia ARM64 build compiles.

Bug: crashpad:196
Change-Id: I1b749a2b2443303ad86122fbe5c9750300474d79
Reviewed-on: https://chromium-review.googlesource.com/925454
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-20 15:18:40 +00:00
Scott Graham
10222b1236 fuchsia: Disable TimeZone.Basic test as timezones are non-functional
TZ related functionality isn't working in Fuchsia right now
https://fuchsia.googlesource.com/zircon/+/master/third_party/ulib/musl/src/time/__tz.c#9
so this test has no chance of working. Disable for now.

Bug: crashpad:196
Change-Id: I77c3d38e5f5fc98f2e7bf8c493df269eb142ce75
Reviewed-on: https://chromium-review.googlesource.com/923201
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-16 18:54:38 +00:00
Scott Graham
0403602393 Fix CrashpadInfoSizes_ClientOptions/CrashpadInfoSizes_ClientOptions
These tests needed to be updated to expose CrashpadInfo in the same way
as the main CrashpadInfo g_crashpad_info is found on
Linux/Android/Fuchsia.

Unfortunately, while the tests pass on Fuchsia when run in isolation,
the implementation of dlclose() on Fuchsia currently does nothing. So,
if the full test suite is run, there's interference between the test
modules (i.e. the values in _small vs. the values in _large), so the
tests fail.

I filed ZX-1728 upstream about this to see if it might be implemented,
or if the test will need to spawn a clean child to do the module load
tests in.

Bug: crashpad:196
Change-Id: I9ee01b142a29c508c6967dc83da824afa254d379
Reviewed-on: https://chromium-review.googlesource.com/923182
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-16 18:48:58 +00:00
Scott Graham
6798ba912e Reset CrashpadInfo after CrashpadInfoReader tests
In preference to (the reverted)
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/923178
this does not share implementation with the tests in
snapshot/crashpad_info_client_options_test.cc. This is not done because
those tests use faked CrashpadInfo structures that are intentionally
differently sized than the current defintion of CrashpadInfo, meaning
that the scoped reset could overwrite past the end of the structure.

Not resetting these was causing CrashpadInfoClientOptions tests to fail
on Fuchsia, because dlclose() [legally] doesn't do anything, so
modifying the current binaries CrashpadInfo caused the expected values
from child .sos to be ignored. That could be worked around in that test
too, but it's probably better to clean up the global state in this test
anyway.

Bug: crashpad:196
Change-Id: Ia3f81f1d5872b5ef7d543fcc68b56af4c0b6ca0a
Reviewed-on: https://chromium-review.googlesource.com/923561
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-16 04:56:01 +00:00
Scott Graham
f9d160ffc6 Revert "Reset CrashpadInfo after CrashpadInfoReader tests"
This reverts commit 4717300fa4cefadeabef64346ba65aa8759d43b8.

Reason for revert: When used in with the size-testing fake CrashpadInfo's, this can overwrite past the end of them.

Original change's description:
> Reset CrashpadInfo after CrashpadInfoReader tests
> 
> Not resetting these was causing CrashpadInfoClientOptions tests to fail
> on Fuchsia, because dlclose() [legally] doesn't do anything, so
> modifying the current binaries CrashpadInfo caused the expected values
> from child .sos to be ignored. That could be worked around in that test
> too, but it's probably better to clean up the global state in this test
> anyway.
> 
> Bug: crashpad:196
> Change-Id: Ia8119ac7c554bea81e8373e2547faf192c629122
> Reviewed-on: https://chromium-review.googlesource.com/923178
> Commit-Queue: Scott Graham <scottmg@chromium.org>
> Reviewed-by: Joshua Peraza <jperaza@chromium.org>

TBR=scottmg@chromium.org,jperaza@chromium.org

Change-Id: Ia6d8db1ba24c82bb9346210ac8b66d80f42a6925
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: crashpad:196
Reviewed-on: https://chromium-review.googlesource.com/923541
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-16 03:41:10 +00:00
Scott Graham
4717300fa4 Reset CrashpadInfo after CrashpadInfoReader tests
Not resetting these was causing CrashpadInfoClientOptions tests to fail
on Fuchsia, because dlclose() [legally] doesn't do anything, so
modifying the current binaries CrashpadInfo caused the expected values
from child .sos to be ignored. That could be worked around in that test
too, but it's probably better to clean up the global state in this test
anyway.

Bug: crashpad:196
Change-Id: Ia8119ac7c554bea81e8373e2547faf192c629122
Reviewed-on: https://chromium-review.googlesource.com/923178
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-02-16 03:20:59 +00:00
Scott Graham
eec1e17ab5 Fix two bugs in memset()ing CrashpadInfo on size mismatch
In trying to clear out the end of info when the alleged size is smaller
than the current structure size, we didn't handle the opposite case. We
need to continue the rest of Read() to initialize members, but need to
make sure not to pass a very large (negative -> size_t) length to
memset().

Additionally, I believe it meant to memset from the end of the alleged
size, to the end of the local structure, rather than from the beginning
of the structure.

This repro'd on Fuchsia, but would affect all platforms that use it.

Bug: crashpad:196, crashpad:30
Change-Id: I9c35c834010b5cb26d54156ce8f9bc538dcbf96c
Reviewed-on: https://chromium-review.googlesource.com/923094
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-02-16 00:03:41 +00:00
Joshua Peraza
a4d7fb4cc3 Use .long for pointers on 32-bit platforms
Placing a 32-bit pointer directly into a .quad results in either an
unsupported relocation error at link time (ARM) or an inability to
load the executable (x86).

Also, only attempt to read a module's CrashpadInfo if an info address
note was found.


Change-Id: I053af3d77eed70af66248be88547656d2b29878a
Reviewed-on: https://chromium-review.googlesource.com/922397
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-02-15 21:55:21 +00:00
Scott Graham
b43858c990 fuchsia: Start of ModuleSnapshot and ProcessReader implementations
Adds beginning ProcessReader implementation for Fuchsia which currently
only reads modules from the target process. ModuleSnapshotFuchsia
implemented enough to pull out CrashpadInfo, which in turn is passed
through ProcessSnapshotFuchsia, which is enough to get
CrashpadInfoClientOptions.OneModule to pass.

Bug: crashpad:196
Change-Id: I92b82696c464a5ba2e0db2c75aa46fd74b0fa364
Reviewed-on: https://chromium-review.googlesource.com/910324
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-15 21:24:01 +00:00
Scott Graham
7faa2ef898 Get CrashpadInfo address via a .note, rather than dynamic symtab
Embeds the address of g_crashpad_info into a .note section (which is
readable by the generic code to read notes in ElfImageReader).
Unfortunately because the note section is in libclient.a, it would
normally be dropped at link time.  To avoid that, GetCrashpadInfo() has
a reference *back* to that section, which in turn forces the linker to
include it, allowing the note reader to find it at runtime.

Previously, it was necessary to have the embedder of "client" figure out
how to cause `g_crashpad_info` to appear in the final module's dynamic
symbol table.  With this new approach, there's no manual configuration
necessary, as it's not necessary for the symbol to be exported.

This is currently only implemented in the Linux module reader (and I
believe the current set of enabled tests aren't exercising it?) but it
will also be done this way for the Fuchsia implementation of
ModuleSnapshot.

Bug: crashpad:196
Change-Id: I599db5903bc98303130d11ad850ba9ceed3b801a
Reviewed-on: https://chromium-review.googlesource.com/912284
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-02-15 19:02:12 +00:00
Joshua Peraza
38b20ca57e Relocate CaptureContext to misc and implement on Linux
Previously, the mac version was  under client/ and win under util/win/.
This cl brings them all together under util/misc/ and combines common
test code.

Bug: crashpad:30
Change-Id: Idf0d0158b969d5aa9802dfc8c21f73041b2bcc6c
Reviewed-on: https://chromium-review.googlesource.com/907755
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-02-09 17:25:45 +00:00
Scott Graham
9ab4fbf1e1 win: Improve child crash location test
In setting up the gn build, slightly different optimization settings
were applied for release builds. This caused a couple things to happen,
1) the sketchy noinline declspec was ignored, and 2) the distance
between reading the IP and the actual crash exceeded the tolerance of 64
bytes in the parent.

To make the test more robust to this, use CaptureContext() (I think our
improved version didn't exist at the time the tests was originally
written). Also, switch from crashpad::CheckedWriteFile to Windows'
WriteFile(), which avoids inlining a whole lot of code at that point.
The return value is not checked, but the next thing that happens is that
the function crashes unconditionally, so this does not seem like a huge
problem.

Bug: crashpad:79
Change-Id: I8193d8ce8b01e1533c16b207813c36d6d6113d89
Reviewed-on: https://chromium-review.googlesource.com/902693
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-06 21:27:39 +00:00
Scott Graham
36679d572b win: Don't assume offsets the same when kDoesNotObserveDaylightSavingTime
kDoesNotObserveDaylightSavingTime can indicate only that the
standard/daylight transition is not automatic, as opposed to it not
existing at all.

Bug: crashpad:214
Change-Id: Ib7016806e79465a6dde605dd667b75a802e1b6c5
Reviewed-on: https://chromium-review.googlesource.com/904767
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-06 20:03:28 +00:00
Scott Graham
14dbd3531d gn win: Get main test binaries building
- default to subsystem:console
- don't build posix/timezone.*
- add some missing libs

This gets all the main binaries building and running. Most configs pass,
but there's some offsets that seem different in some builds; need to
investigate more. Additionally, the binaries used by end_to_end_test.py
aren't yet built, so that script fails.

Includes mini_chromium roll to 46eeaf9:
46eea49 gn win: Add debug info and pdb to cc/cxx
902a29f gn win: Various fixes towards making GN build work

Bug: crashpad:79
Change-Id: Ie56a469b84bed7b0330172cec9f1a8aeb95f702e
Reviewed-on: https://chromium-review.googlesource.com/902403
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-06 19:12:18 +00:00
Scott Graham
0dd11f6341 gn: Guard addition of ELF test target
Fix Windows- and Mac-in-Chromium GN builds.

Bug: crashpad:79
Change-Id: I952f364ed679a13f656a8db18fb4d1fbf5858c17
Reviewed-on: https://chromium-review.googlesource.com/900206
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-02 22:09:55 +00:00
Scott Graham
9b6c69cbb5 Coalesce memory ranges
Follows https://chromium-review.googlesource.com/c/374019/.

Causes MinidumpMemoryListWriter to merge all overlapping ranges before
writing the MINIDUMP_MEMORY_LIST. This is:

1) Necessary for the Google internal crash processor, which in some
   cases attempts to read the raw memory (displaying ASAN red zones),
   and aborts if there are any overlapping ranges in the minidump on
   load;

2) Necessary for new-ish versions of windbg (see bug 216 below). It is
   believed that this is a change in behavior in the tool that made
   dumps with overlapping ranges unreadable;

3) More efficient. The .dmp for crashy_program goes from 306K to 140K
   with this enabled. In Chrome minidumps where
   set_gather_indirectly_referenced_memory() is used (in practice this
   means Chrome Windows Beta, Dev, and Canary), the savings are expected
   to be substantial.

Bug: crashpad:61, chromium:638370, crashpad:216

Change-Id: I969e1a52da555ceba59a727d933bfeef6787c7a5
Reviewed-on: https://chromium-review.googlesource.com/374539
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-02 00:04:20 +00:00
Scott Graham
75ae5bae78 Rework CrashpadInfoReader tests to not require fork()
Avoid fork() so that the tests can work on Fuchsia. Fills out
CrashpadInfo in the child, and then sends the addresses of various
structures to the parent process to be used for expectation checking.

Bug: crashpad:196, crashpad:215
Change-Id: I9ace6671d2e9184d48fe33016a01271ccfbcbfb6
Reviewed-on: https://chromium-review.googlesource.com/894705
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-01-31 18:01:59 +00:00
Joshua Peraza
3f0371cce2 Define ElfImageReader::Memory()
Bug: crashpad:30
Change-Id: Ibb6c6423736daa9fb248ac0c8d724244906236d4
Reviewed-on: https://chromium-review.googlesource.com/894447
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-31 17:06:59 +00:00
Scott Graham
1f1657d573 Read either DT_HASH or DT_GNU_HASH to determine the size of DT_SYMTAB
Without the section headers for the symbol table, there's no direct way
to calculate the number of entries in the table.

DT_HASH and DT_GNU_HASH are auxiliary tables that are designed to make
symbol lookup faster. DT_HASH is the original and is theoretically
mandatory. DT_GNU_HASH is the new-and-improved, but is more complex.

In practice, however, an Android build (at least vs. API 16) has only
DT_HASH, and not DT_GNU_HASH, and a Fuchsia build has only DT_GNU_HASH
but not DT_HASH. So, both are tried.

This change does not actually use the data in these tables to improve
the speed of symbol lookup, but instead only uses them to correctly
terminate the linear search.

DT_HASH contains the total number of symbols in the symbol table fairly
directly because there is an entry for each symbol table entry in the
hash table, so the number is the same.

DT_GNU_HASH regrettably does not. Instead, it's necessary to walk the
buckets and chain structure to find the largest entry.

DT_GNU_HASH doesn't appear in any "real" documentation that I'm aware
of, other than the binutils code (at least as far as I know). Some
more-and-less-useful references:
- https://flapenguin.me/2017/04/24/elf-lookup-dt-hash/
- https://flapenguin.me/2017/05/10/elf-lookup-dt-gnu-hash/
- http://deroko.phearless.org/dt_gnu_hash.txt
- https://sourceware.org/ml/binutils/2006-10/msg00377.html

Change-Id: I7cfc4372f29efc37446f0931d22a1f790e44076f
Bug: crashpad:213, crashpad:196
Reviewed-on: https://chromium-review.googlesource.com/876879
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-01-30 22:40:17 +00:00
Joshua Peraza
c9244d58df Add ARM family minidump support
Bug: crashpad:30
Change-Id: I6784d42ba6c525c4e0b16dfdbbb4949c83e32fea
Reviewed-on: https://chromium-review.googlesource.com/888541
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-30 20:47:28 +00:00
Scott Graham
c04352a2e6 Rework ElfImageReader.OneModuleChild to not rely on fork()
Switches from test::Multiprocess to test::MultiprocessExec for
ElfImageReader.OneModuleChild.

Uses the new child process launching, and passes the address of libc and
the address of getpid from the child to parent, rather than assuming the
values will be the same in both processes.

And, enables the test on Fuchsia since it now works.

Bug: crashpad:196, crashpad:215
Change-Id: I3650c16c4fccfe9c1e4147192fdc88b997460060
Reviewed-on: https://chromium-review.googlesource.com/887373
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-25 23:02:20 +00:00
Scott Graham
11589d9b32 Rework ElfImageReader.MainExecutableChild to not rely on fork()
Switches from test::Multiprocess to test::MultiprocessExec for
ElfImageReader.MainExecutableChild.

Uses the new child process launching, and passes the expected symbol
address from the child to the parent, rather than assuming the value
will be the same in both processes.

And, enables the test on Fuchsia since it now works.

Bug: crashpad:196, crashpad:215
Change-Id: I3b43407b6584275d61bedc9c13d1625b950fc23b
Reviewed-on: https://chromium-review.googlesource.com/884993
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-25 23:00:49 +00:00
Mostyn Bramley-Moore
26cd6138af [jumbo] add some missing include guards
Change-Id: I062c853d65c3e89a61920d790d9bc5c993b46fcd
Reviewed-on: https://chromium-review.googlesource.com/884581
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-01-24 22:45:01 +00:00
Joshua Peraza
c56e854984 Fix Doxygen errors
Change-Id: I571d322e75afd33a679c488694db2e7bad3285ea
Reviewed-on: https://chromium-review.googlesource.com/883903
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-24 18:21:15 +00:00
Joshua Peraza
24f07f7c43 linux: Enable ARM family exception and thread snapshots
ARM references:
http://elixir.free-electrons.com/linux/latest/source/arch/arm/include/asm/ucontext.h
http://elixir.free-electrons.com/linux/latest/source/arch/arm/kernel/signal.c#L185

ARM64 references:
http://elixir.free-electrons.com/linux/latest/source/arch/arm64/include/uapi/asm/sigcontext.h
http://elixir.free-electrons.com/linux/latest/source/arch/arm64/kernel/signal.c#L371

Bug: crashpad:30
Change-Id: I53f235b5826607db260bd1e43a819a93284843f5
Reviewed-on: https://chromium-review.googlesource.com/865435
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-24 17:09:24 +00:00
Scott Graham
dea19c7374 fuchsia: Port ElfImageReader and (some of) its tests
(Still need to avoid fork()-dependence for the non-self tests.)

Bug: crashpad:196
Change-Id: Ib34fe33c7ec295881c1f555995072d9ff742647f
Reviewed-on: https://chromium-review.googlesource.com/876650
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-01-19 22:22:21 +00:00
Scott Graham
9f4ebc713a fuchsia: Get CrashpadInfoReader working
Bug: crashpad:196
Change-Id: Ia9bcc45891fd5cf40cccc655c4b904b1610e5932
Reviewed-on: https://chromium-review.googlesource.com/875117
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-18 22:40:28 +00:00
Joshua Peraza
a459d30e9b android: partially disable module tests on ARM before API 21
ProcessReader module tests use dl_iterate_phdr to check that the
loader's modules appear in the ProcessReader's module vector, but
this API is not provided  on Android for ARM until API 21.

Bug: crashpad:30
Change-Id: I7832bb5560f870671812c42345d4b59bf4416a26
Reviewed-on: https://chromium-review.googlesource.com/871972
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-18 02:59:44 +00:00
Scott Graham
3a07faf171 fuchsia: Fully initialize TestCrashpadInfo structure
The in-Fuchsia build fails with:

../../third_party/crashpad/snapshot/crashpad_info_size_test_module.cc:89:77: error: missing field 'indirectly_referenced_memory_cap_' initializer [-Werror,-Wmissing-field-initializers]
TestCrashpadInfo g_test_crashpad_info = {'CPad', sizeof(TestCrashpadInfo), 1};

kulakowski mentioned in the context of the = {0} CL recently that
they've turned on some somewhat unusual warnings because they have a
higher-than-usual amount of C code, as well as code that has to build as
both C and C++. I think that's where this one comes from.

Bug: crashpad:196
Change-Id: Ie1b373a32f99615366c7fcd65cd4ae4761385ff9
Reviewed-on: https://chromium-review.googlesource.com/862802
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-01-12 00:58:11 +00:00
Joshua Peraza
fa197c267c linux: Collect Crashpad options from CrashpadInfos
Bug: crashpad:30
Change-Id: I233780e97a4b23238995af409c5f40d2e809906b
Reviewed-on: https://chromium-review.googlesource.com/848248
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-10 21:42:27 +00:00
Joshua Peraza
94d65e0e9c linux: Detect memory map failures correctly
Bug: crashpad:30
Change-Id: I3ff66b72621b8b29ce2676778b1f2f404495869f
Reviewed-on: https://chromium-review.googlesource.com/860887
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-10 21:38:57 +00:00
Joshua Peraza
fb379a9242 Add ModuleSnapshotLinux
Bug: crashpad:30
Change-Id: Ibf1f62b82a4926e1dfd9ad92231bfff44b811d78
Reviewed-on: https://chromium-review.googlesource.com/842187
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-10 19:41:47 +00:00
Joshua Peraza
878af9cbbd Add AnnotationReader to read annotation types via a ProcessMemory
Bug: crashpad:30
Change-Id: Icd13d29992b8684ca92916068f12428c25e0e775
Reviewed-on: https://chromium-review.googlesource.com/846519
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-09 21:52:06 +00:00
Joshua Peraza
70563e92f4 Add CrashpadInfoReader to read CrashpadInfo via ProcessMemory
Bug: crashpad:30
Change-Id: I295d518ee0eef1fd61e5544cd6bad25827d07a02
Reviewed-on: https://chromium-review.googlesource.com/846025
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-09 01:27:50 +00:00
Joshua Peraza
8bbe985004 elf: Use d_ptr instead of d_val when reading from a dynamic array
The dynamic array reader should treat data as unsigned when initially
reading values from the array to prevent premature sign-extension. The
glibc and traditional android headers define d_val using Elf32_Word, an
unsigned type. linux/elf.h, used by unified android headers, defines
d_val using Elf32_Sword, a signed type. Use d_ptr instead since it's
always an unsigned type.

Bug: crashpad:30
Change-Id: Ie8e88941fefc7075621aefe226fdba33b1f6129c
Reviewed-on: https://chromium-review.googlesource.com/847818
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-08 23:28:21 +00:00
Mark Mentovai
7a285816e9 gn, android: Build for Android with GN
With a companion mini_chromium change at https://crrev.com/c/841203,
it’s possible to configure via “gn args” as follows:

android_ndk = "/android/android-ndk-r16"
target_cpu = "x86_64"
target_os = "android"

Note that a standalone toolchain is not required.

Bug: crashpad:30, crashpad:79
Change-Id: Ica55bdcb82c730909c05dd9fecb40a74eca78c8a
Reviewed-on: https://chromium-review.googlesource.com/841286
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-12-22 21:23:31 +00:00
Scott Graham
cd7428971f gn: Fix symbol_level use in chromium style
Bug: crashpad:79
Change-Id: I417f17194ee1a8ef157ea1e67e64878ccb6f5c10
Reviewed-on: https://chromium-review.googlesource.com/835528
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2017-12-20 01:55:55 +00:00
Scott Graham
ab153f7e1b gn: Avoid depending on BUILDCONFIG.gn globals
Goes with https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/834648.

Includes mini_chromium DEPS roll to pull in edfe51ce81

Bug: crashpad:79, crashpad:196
Change-Id: Ib45cc738aecf9ae727f8faeff81f3b71e2dc9de8
Reviewed-on: https://chromium-review.googlesource.com/834543
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-19 23:38:36 +00:00
Joshua Peraza
9b2ba587f6 linux: Add ExceptionHandlerServer and ExceptionHandlerClient
Bug: crashpad:30
Change-Id: I60874a26ccb281144f870df2b4d16c6970a39f6b
Reviewed-on: https://chromium-review.googlesource.com/772824
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-19 20:11:52 +00:00
Mark Mentovai
99b0030616 gn, linux: Build for Linux with GN
This is sufficient for a native Linux build using GN. Android is not yet
supported.

mini_chromium side: https://crrev.com/c/833407

This also updates mini_chromium to 404f6dbf9928.

c913ef97a236 gn, linux: Build for Linux with GN
404f6dbf9928 gn: Don’t use .rsp files; rationalize descriptions and
             output dirs

Bug: crashpad:79
Change-Id: I4f3b72fd02884d77812e520fb95231b35815677d
Reviewed-on: https://chromium-review.googlesource.com/833408
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-12-19 19:31:20 +00:00
Scott Graham
457cc6a34f gn: Refactor build files to avoid build/secondary
In doing standalone bringup of Crashpad targeting Fuchsia, it seemed
tidy to keep the same literal paths to the dependencies that Chromium
needed and add stubs/forwarding to build/secondary in the Crashpad tree
as required to make those work.

However, when trying to build Crashpad in the Fuchsia tree itself, that
would require adding forwarding files to the Fuchsia tree to match the
Chromium directory structure, which would be awkward. Instead, have
explicit dependencies in the Crashpad tree that select the locations
for various dependencies.

Bug: crashpad:79, crashpad:196
Change-Id: Ib506839f9c97d8ef823663cdc733cbdcfa126139
Reviewed-on: https://chromium-review.googlesource.com/826025
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-18 22:53:58 +00:00
Joshua Peraza
0924e56751 linux: Add PtraceBroker and PtraceClient
A PtraceBroker/Client pair implement a PtraceConnection over a socket.
The broker runs in a process with `ptrace` capabilities for the target
process and serves requests for the client over a socket.

Bug: crashpad:30
Change-Id: Ied19bcedf84b46c8f68440fd1c284b2126470e5e
Reviewed-on: https://chromium-review.googlesource.com/780397
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-11 18:35:24 +00:00
Mark Mentovai
c04c05564d linux: Fix gcc -Wparentheses error from 7a0daa6989a9
../../snapshot/elf/elf_image_reader.cc:261:29: error: suggest parentheses around ‘-’ in operand of ‘&’ [-Werror=parentheses]
 #define PAD(x) ((x) + align - 1 & ~(align - 1))
                 ~~~~~~~~~~~~^~~
../../snapshot/elf/elf_image_reader.cc:262:26: note: in expansion of macro ‘PAD’
   size_t padded_namesz = PAD(note_info.n_namesz);
                          ^~~

Change-Id: I5cabc2741c8541ae9cf66933d35658e1cbc20912
Reviewed-on: https://chromium-review.googlesource.com/817575
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-12-08 22:53:11 +00:00
Scott Graham
6719610b8c fuchsia: Get crashpad_snapshot_test building
ProcessSnapshotFuchsia is just a stub, so running fails immediately.

Bug: crashpad:196
Change-Id: Ie281cc13c4ff4a6e9699e882dbd6207daaab346d
Reviewed-on: https://chromium-review.googlesource.com/809234
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2017-12-06 17:31:57 +00:00
Joshua Peraza
7a0daa6989 Enable reading notes from ELF images
Bug: crashpad:30
Change-Id: Ie6c594b05c6d39a869ed30b7a7b49e6a6301cc65
Reviewed-on: https://chromium-review.googlesource.com/792539
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-05 19:27:37 +00:00
Scott Graham
9465fc72ad gn: Move sources out to explicit blocks
This avoids relying on set_sources_assignment_filter, and so gets closer
to a correct set of files to build on Fuchsia.

Bug: crashpad:79, crashpad:196
Change-Id: Ib7daa5137935113c6645b72eb1dedd943a9db96e
Reviewed-on: https://chromium-review.googlesource.com/797672
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2017-11-29 20:36:48 +00:00
Mark Mentovai
ef3ce94fbf Python 3 support for Python scripts (without compromising Python 2)
It’s better to be prepared for the future than…to not be.

This is mostly the result of running 2to3 on all .py files, with some
small shims to maintain compatibility with Python 2.
http_transport_test_server.py was slightly more involved, requiring many
objects to change from “str” to “bytes”.

The #! lines and invokers still haven’t changed, so these scripts will
still normally be interpreted by Python 2.

Change-Id: Idda3c5650f967401a5942c4d8abee86151642a2e
Reviewed-on: https://chromium-review.googlesource.com/797434
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-11-29 18:47:38 +00:00
Scott Graham
2bb56fafe3 Rework GN files to start to support building standalone, and also in Chromium
- Adds a .gn and a build/BUILDCONFIG.gn that uses mini_chromium's
  build/BUILD.gn.
- Adds some stub BUILD.gn files in locations where Chromium expects them
  (in //build, //testing, //third_party) containing empty targets/configs.
  These are no-ops in standalone builds, but add functionality when
  building in Chromium.  This is in preference to having a global bool
  that conditionally does Chromium-y things in the Crashpad build files.
  These stub files are all contained in a secondary source root in
  build/chromium_compatibility, referred to by //.gn.
- Adds //base/BUILD.gn which forwards to mini_chromium/base. This is
  only used when building standalone so that both Chromium and Crashpad
  can refer to it as "//base".
- Changes references to other Crashpad targets to be relatively
  specified so that they work when the root of the project is //, and also
  when it's //third_party/crashpad/crashpad as it is in Chromium.
- Moves any error-causing Mac/Win-specific files into explicit if (is_mac)
  or if (is_win) blocks as part of removing the dependency on
  set_sources_assignment_filter().

As yet unresolved:
- CRASHPAD_IN_CHROMIUM needs to be removed when standalone; to be tackled
  in a follow up.
- Not sure what to do with zlib yet, the build file currently assumes
  "in Chromium" too, and similarly having Crashpad //third_party/zlib:zlib
  pointing at itself doesn't work.

Bug: crashpad:79
Change-Id: I6a7dda214e4b3b14a60c1ed285267ab97432a1a8
Reviewed-on: https://chromium-review.googlesource.com/777410
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2017-11-28 20:29:35 +00:00
Mark Mentovai
e9f40ae176 Remove double double words
I ran the thing below (piped to “grep -v namespace”), fixed things up,
and rewrapped comments in the affected file.

import re
import sys

LAST_WORD_RE = re.compile('^.*[\s]+([\w]+)$')
FIRST_WORD_RE = re.compile('^[^\w]+([\w]+).*$')

for path in sys.argv[1:]:
  with open(path) as file:
    line_number = 0
    last_word = None
    for line in file:
      line_number += 1
      first_word = FIRST_WORD_RE.match(line)
      if first_word and first_word.group(1) == last_word:
        print('%s:%u: %s' % (path, line_number - 1, last_word))
      last_word = LAST_WORD_RE.match(line)
      if last_word:
        last_word = last_word.group(1)

Change-Id: Iea9f2a6453d9d9ec17e2f238e09252535d7408bd
Reviewed-on: https://chromium-review.googlesource.com/780284
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-11-20 23:38:48 +00:00
Mark Mentovai
20e5aba1af URL cleanups: switch to HTTPS, fix dead ones, use canonical ones
Change-Id: I4b247d7fae1a212350f8ffcf2bf5ba1fa730f5c1
Reviewed-on: https://chromium-review.googlesource.com/780339
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-11-20 22:23:39 +00:00
Mark Mentovai
94a5a72efa mac: Tests that crash intentionally shouldn’t go to ReportCrash
Crashpad has many tests that crash intentionally. Some of these are
gtest death tests, and others arrange for intentional crashes to test
Crashpad’s own crash-catching logic. On macOS, all of the gtest death
tests and some of the other intentional crashes were being logged by
ReportCrash, the system’s crash reporter. Since these reports
corresponded to intentional crashes, they were never useful, and served
only to clutter ~/Library/Logs/DiagnosticReports.

Since Crashpad is adept at handling exceptions on its own, this
introduces the “exception swallowing server”,
crashpad_exception_swallower, which is a Mach exception server that
implements a no-op exception handler routine for all exceptions
received. The exception swallowing server is established as the task
handler for EXC_CRASH and EXC_CORPSE_NOTIFY exceptions during gtest
death tests invoked by {ASSERT,EXPECT}_DEATH_{CHECK,CRASH}, and for all
child processes invoked by the Multiprocess test infrastructure. The
exception swallowing server is not in effect at other times, so
unexpected crashes in test code can still be handled by ReportCrash or
another crash reporter.

With this change in place, no new reports are generated in the
user-level ~/Library/Logs/DiagnosticReports or the system’s
/Library/Logs/DiagnosticReports during a run of Crashpad’s full test
suite on macOS.

Bug: crashpad:33
Change-Id: I13891853a7e25accc30da21fa7ea8bd7d1f3bd2f
Reviewed-on: https://chromium-review.googlesource.com/777859
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-11-20 18:58:34 +00:00
Scott Graham
d5ead4d70f Upstream lightly modified Chromium BUILD.gn files
Unreferenced, and not working at all in Crashpad-standalone.

Copied from Chromium at 52a9831d81f2099ef9f50fcdaca5853019262c35 to have
a point where a roll back into Chromium should be a no-op (with Chromium's
build/secondary/third_party/crashpad/... removed).

I'm not sure what we want to do about the various gni references into
Chromium (e.g. //build/config/sanitizers/sanitizers.gni, //testing/test.gni,
etc.) but I guess the sooner they live in Crashpad rather than in Chromium
the sooner we can figure out the sort of knobs and dials we need.

Bug: crashpad:79
Change-Id: Id99c29123bcd4174ee2bcc128c2be87e3c94fa3f
Reviewed-on: https://chromium-review.googlesource.com/777819
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2017-11-20 18:08:23 +00:00
Mark Mentovai
d7798a4e28 Tolerate safe size mismatches in the CrashpadInfo struct
The handler will now be less strict about checking CrashpadInfo struct
sizes. Assuming the signature and version fields match:

 - If the handler sees a struct smaller than it’s expecting, the module
   was likely built with an earlier version of the client library, and
   it’s safe to treat the unknown fields as though they were zero or
   other suitable default values.
 - If the handler sees a struct larger than it’s expecting, the module
   was likely built with a later version of the client library. In that
   case, actions desired by the client will not be performed, but this
   is not otherwise an error condition.

The CrashpadInfo struct must always be at least large enough to contain
at least the size field. The signature and version fields are always
checked.

The section size must be at least as large as the size carried within
the struct. To account for possible section padding, strict equality is
not required.

Bug: chromium:784427
Test: crashpad_snapshot_test CrashpadInfoSizes_ClientOptions/*.*
Change-Id: Ibb0690ca6ed5e7619d1278a68ba7e893d55f19fb
Reviewed-on: https://chromium-review.googlesource.com/767709
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-11-15 18:09:23 +00:00
Mark Mentovai
0e3c38a4ca win: Make ProcessSnapshotTest.CrashpadInfoChild use a loaded module
When this test examines a module that doesn’t have a CodeView PDB link,
it will fail. Such a link may be missing when linking with Lexan
ld-link.exe without /DEBUG. The test had been examining the executable
as its module. Since it’s easier to provide a single small module linked
with /DEBUG than it is to require that the test executable always be
linked with /DEBUG, the test is revised to always load a module and
operate on it. The module used is the existing
crashpad_snapshot_test_image_reader_module.dll. It was chosen because
it’s also used by PEImageReader.DebugDirectory, which also requires a
CodeView PDB link.

It’s the build system’s responsibility to ensure that
crashpad_snapshot_test_image_reader_module.dll is linked appropriately.
Crashpad’s own GYP-based build always links with /DEBUG. Chrome’s
GN-based Crashpad build will require additional attention at
symbol_level = 0.

Bug: chromium:782781
Change-Id: I0dda8cd13278b82842263e76bcc46362bd3998df
Reviewed-on: https://chromium-review.googlesource.com/761501
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-11-09 23:18:51 +00:00
Mark Mentovai
e2b9ab3ed2 win: Tests shouldn’t freak out when CodeView PDB links are absent
crashpad_snapshot_test PEImageReader.DebugDirectory was hanging when
crashpad_snapshot_test_image_reader.exe did not have a CodeView PDB
link. This occurred when linked by Lexan ld-link.exe without /DEBUG.

Bug: chromium:782781
Change-Id: I8fbc4d8decf6ac5e19f7ffeb230fd15d7c40fd51
Reviewed-on: https://chromium-review.googlesource.com/761320
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-11-09 23:17:27 +00:00
Mark Mentovai
2d077a2c57 win: Use “long” format modifier for DWORD
Change-Id: Ibecedd195224ea53ff36f376897a6ff3c4e773d2
Reviewed-on: https://chromium-review.googlesource.com/757085
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-11-07 21:46:36 +00:00
Mark Mentovai
d3b7463c7a win: Recognize nsi.dll presenting as VFT_DRV/VFT2_DRV_NETWORK
This was previously proposed at
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/339103/2/util/win/pe_image_reader_test.cc#84.
It didn’t land because the change was abandoned for other reasons, but
the fix was valid. nsi.dll is not VFT_APP or VFT_DLL, and if it’s
loaded, crashpad_snapshot_test PEImageReader.VSFixedFileInfo_AllModules
fails.

Although I can’t reproduce nsi.dll being loaded spontaneously in local
testing or on trybots, it occurred in the monolithic crashpad_tests at
https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/64492:

[ RUN      ] PEImageReader.VSFixedFileInfo_AllModules
../../third_party/crashpad/crashpad/snapshot/win/pe_image_reader_test.cc(90): error: Value of: observed.dwFileType == VFT_APP || observed.dwFileType == VFT_DLL
  Actual: false
Expected: true
Google Test trace:
../../third_party/crashpad/crashpad/snapshot/win/pe_image_reader_test.cc(164): C:\Windows\syswow64\NSI.dll
[  FAILED  ] PEImageReader.VSFixedFileInfo_AllModules (11 ms)

I can also reproduce locally by calling LoadLibrary(L"nsi.dll").

Bug: chromium:779790, chromium:782011
Test: crashpad_snapshot_test PEImageReader.VSFixedFileInfo_AllModules
Change-Id: I361c7d6521645913277a441ce38779aaa4a182c2
Reviewed-on: https://chromium-review.googlesource.com/757077
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-11-07 17:42:18 +00:00
Joshua Peraza
18726100ed Move win/time to misc/time and add more conversion functions
This CL pulls together similar time conversion functions and adds
conversions between `FILETIME`s and `timespec`s.

Bug: crashpad:206
Change-Id: I1d9b1560884ffde2364af0092114f82e1534ad1c
Reviewed-on: https://chromium-review.googlesource.com/752574
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-06 22:37:27 +00:00
Joshua Peraza
d768538e39 Add ProcessSnapshotLinux
Bug: crashpad:30
Change-Id: Ie03592aeb91741d957b98716e4d4bb19695a42cf
Reviewed-on: https://chromium-review.googlesource.com/604627
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2017-11-03 16:49:28 +00:00
Robert Sesek
b6a3d91342 Read annotation objects from the client when producing snapshots.
This wires up the annotation objects system of the client to the
snapshot production and minidump writing facilities.

Bug: crashpad:192
Change-Id: If7bb7625b140d71a15b84729372cbd0fd4bc63ef
Reviewed-on: https://chromium-review.googlesource.com/749870
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
2017-11-02 16:40:48 +00:00
Mark Mentovai
2db30e035a win: Fix Clang -Wsign-compare warnings in new test code
This test code appeared in 9609b7471676, and was missed by the similar
warning cleanup of a51e912004a6, which was developed in parallel.

Bug: crashpad:192, chromium:779790
Change-Id: I4ed88ed025e4be4410c98ceaca395218f00007be
Reviewed-on: https://chromium-review.googlesource.com/750024
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-11-02 15:16:59 +00:00
Robert Sesek
620a29dbf3 Add support for reading annotation objects in ModuleSnapshotMinidump.
This will be used to include the annotations as form-post data when
uploading reports.

Bug: crashpad:192
Change-Id: I85ba9afd3cae7c96c0f8fe4f31a2460c97ed42d3
Reviewed-on: https://chromium-review.googlesource.com/747514
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-01 23:08:55 +00:00
Robert Sesek
f9e587b036 Remove NOTREACHED() in ModuleSnapshot::AnnotationObjects() impls.
This is causing crashpad_handler_test to fail in Debug on Windows.

Bug: crashpad:192
Change-Id: Icf3ff387050ee2becf471f4e7c3a75394b1dd436
Reviewed-on: https://chromium-review.googlesource.com/749792
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-01 22:16:43 +00:00
Mark Mentovai
4f5524fc68 Fix Windows build after 81eced5192d9
81eced5192d9 added a a dependency on
crashpad_snapshot_test_simple_annotations to crashpad_snapshot_test, but
9609b7471676 renamed this target to crashpad_snapshot_test_annotations.

I should have rebased onto HEAD, rebuilt, and retested before landing.
Bad developer! No candy. 🎃

Change-Id: I8fcd1020d8bd4ee163afa555ae6e815325485024
Reviewed-on: https://chromium-review.googlesource.com/748814
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-11-01 17:02:27 +00:00
Mark Mentovai
43b798b492 test: Fix paths for crashpad_tests monolith in Chromium
Instead of individual per-directory test executables like
crashpad_util_test, all Crashpad tests in Chromium will be run from a
single crashpad_tests executable.

Test: crashpad_util_test Paths.Executable, ProcessInfo.Self; crashpad_snapshot_test PEImageReader.DebugDirectory
Bug: chromium:779790
Change-Id: If95272fd641734fbdb8e231fbcdc4e7ccb2cb822
Reviewed-on: https://chromium-review.googlesource.com/749303
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-11-01 17:00:30 +00:00
Mark Mentovai
1669ca2bac test: Rework TestPaths interface for obtaining 32-bit build artifacts
The design for running all Crashpad unit tests on Chromium’s try- and
buildbots involves pulling all tests into a single monolithic
crashpad_tests executable. Many Crashpad tests base the name of their
child executables or modules on the name of the main test executable.
Since the main test executable will have a different name in the
in-Chromium build, knowledge of the test executable name (referred to as
“module” here) needs to be added to the tests themselves.

This introduces TestPaths::BuildArtifact(), which allows the module name
to be specified. For Crashpad’s standalone build, the module name is
verified against the main test executable’s name.
TestPaths::BuildArtifact() can also locate paths in the alternate 32-bit
output directory for 64-bit Windows tests, taking on the responsibility
for what the new (5e9ed4cb9f69) TestPaths::Output32BitDirectory(), now
obsolete, did.

Bug: chromium:779790
Change-Id: I64c4a2190b6319e487c999812a7cfc512a75a700
Reviewed-on: https://chromium-review.googlesource.com/747536
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-11-01 16:44:45 +00:00
Mark Mentovai
a51e912004 Fix warnings produced by trunk clang in test code
These are mostly -Wsign-compare warnings, with a -Wconstant-conversion
and a -Wunguarded-availability thrown in.

Bug: chromium:779790
Change-Id: Ic2103f3332ce57378db83eca7fa2569efec1a7b6
Reviewed-on: https://chromium-review.googlesource.com/746081
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-11-01 16:35:49 +00:00
Mark Mentovai
81eced5192 snapshot: Specify test dependencies properly
Two dependency targets were missing from crashpad_snapshot_test.

Change-Id: I9efba73639e529313d4aa49df5e68bb5117cf95a
Reviewed-on: https://chromium-review.googlesource.com/746121
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-11-01 16:27:55 +00:00
Robert Sesek
9609b74716 Expand the PEImageAnnotationsReader to read Annotation objects.
Nothing currently directs the handler to read these Annotation objects
from the target process, so they will not be read by Crashpad nor appear
in the minidump.

Bug: crashpad:192
Change-Id: I1eb1e9f42282c07e37d335631f0cc6083ef28a89
Reviewed-on: https://chromium-review.googlesource.com/726501
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-31 22:40:38 +00:00
Robert Sesek
e4723d524f Expand the MachOImageAnnotationsReader to read Annotation objects.
Nothing currently directs the handler to read these Annotation objects
from the target process, so they will not be read by Crashpad nor appear
in the minidump.

Bug: crashpad:192
Change-Id: I8ebabb4f5c77c5620b0d8e5036c3185eecfa4646
Reviewed-on: https://chromium-review.googlesource.com/717236
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-31 22:18:10 +00:00
Robert Sesek
b88fde0b56 Add the AnnotationSnapshot object and attach it to ModuleSnapshot.
The AnnotationSnapshot is the handler-side of the Annotation object,
which will store the annotation data when read by a ProcessReader.

Bug: crashpad:192
Change-Id: Ic65c95022c452522678c1070c27c429dd631fb64
Reviewed-on: https://chromium-review.googlesource.com/717197
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-31 18:24:41 +00:00
Mark Mentovai
5e9ed4cb9f win: Dynamically disable WoW64 tests absent explicit 32-bit build output
Rather than having the 64-bit build assume that it lives in
out\{Debug,Release}_x64 and that it can find 32-bit build output in
out\{Debug,Release}, require the location of 32-bit build output to be
provided explicitly via the CRASHPAD_TEST_32_BIT_OUTPUT environment
variable. If this variable is not set, 64-bit tests that require 32-bit
test build output will dynamically disable themselves at runtime.

In order for this to work, a new DISABLED_TEST() macro is added to
support dynamically disabled tests. gtest does not have its own
first-class support for this
(https://groups.google.com/d/topic/googletestframework/Nwh3u7YFuN4,
https://github.com/google/googletest/issues/490) so this local solution
is used instead.

For tests via Crashpad’s own build\run_tests.py, which is how Crashpad’s
own buildbots and trybots invoke tests, CRASHPAD_TEST_32_BIT_OUTPUT is
set to a locaton compatible with the paths expected for the GYP-based
build. No test coverage is lost on Crashpad’s own buildbots and trybots.

For Crashpad tests in Chromium’s buildbots and trybots, this environment
variable will not be set, causing these tests to be dynamically
disabled.

Bug: crashpad:203, chromium:743139, chromium:777924
Change-Id: I3c0de2bf4f835e13ed5a4adda5760d6fed508126
Reviewed-on: https://chromium-review.googlesource.com/739795
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-10-26 18:31:57 +00:00
Robert Sesek
34699d378b Create client data structures for typed Annotations.
This introduces the Annotation object, used to declare typed
annotations, and the AnnotationList object, used to reference these. The
AnnotationList is referenced by the CrashpadInfo structure. Currently
nothing reads these.

The AnnotationList implements a lock-free linked list, into which
Annotation objects are added exactly once, when they are first set.
Clearing an Annotation merely marks it internally as such, rather than
removing it from the list.

Bug: crashpad:192
Change-Id: I72414b1f83d624c4ae323e09ecea8cfb69a68c5e
Reviewed-on: https://chromium-review.googlesource.com/547135
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
2017-10-25 21:56:20 +00:00
Mark Mentovai
52d766400d linux: ProcessReader can own ProcessMemoryLinux without unique_ptr
There’s no reason for ProcessReader to own its ProcessMemoryLinux via
std::unique_ptr<>.

This was discovered in a trunk Clang build, during which a
-Wdelete-non-virtual-dtor warning was produced (since Clang r312167).
The warning is not produced by earlier Clang versions or by GCC because
the “delete” happens in a system header, <memory>, when performed by
std::unique_ptr<>. Although ownership via std::unique_ptr<> is no longer
used, ProcessMemoryLinux is marked “final” because it ought to be.

In file included from ../../snapshot/linux/process_reader.cc:15:
In file included from ../../snapshot/linux/process_reader.h:21:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../include/c++/7.2.0/memory:80:
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../include/c++/7.2.0/bits/unique_ptr.h:78:2: error: delete called on non-final 'crashpad::ProcessMemoryLinux' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
        delete __ptr;
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../include/c++/7.2.0/bits/unique_ptr.h:268:4: note: in instantiation of member function 'std::default_delete<crashpad::ProcessMemoryLinux>::operator()' requested here
          get_deleter()(__ptr);
          ^
../../snapshot/linux/process_reader.cc:169:16: note: in instantiation of member function 'std::unique_ptr<crashpad::ProcessMemoryLinux, std::default_delete<crashpad::ProcessMemoryLinux> >::~unique_ptr' requested here
ProcessReader::ProcessReader()
               ^
1 error generated.
Change-Id: Ibe9671db429262aca12bbfdf457c8f72cad2f358
Reviewed-on: https://chromium-review.googlesource.com/738530
Reviewed-by: Dave Bort <dbort@google.com>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-10-25 20:07:29 +00:00
Mark Mentovai
8b63f1f00a snapshot/linux: Fix #includes
From edf4dde8ae10: one #include was missing, and another was sorted
incorrectly.

Change-Id: I77825f3909ae81ebf965f8c5527b44c95af29945
Reviewed-on: https://chromium-review.googlesource.com/734229
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-10-23 21:07:05 +00:00
Mark Mentovai
419f25eac8 Remove PointerVector<> and replace with std::vector<std::unique_ptr<>>
As mentioned at
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/721978/13/tools/crashpad_http_upload.cc#90
Change-Id: I4820346cc0b0bf26633e1de598c884af8af19983
Reviewed-on: https://chromium-review.googlesource.com/724744
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-10-19 04:53:36 +00:00
Joshua Peraza
474c7331a6 Add DirectoryReader to iterate over files in a directory
This change also adds functions to create directories, remove files and
directories, and check for the existence of files and directories.

Change-Id: I62b78219ae2b277d6976d2d90ec86fcabd0ef073
Reviewed-on: https://chromium-review.googlesource.com/696132
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-16 19:56:54 +00:00
Dave Bort
906fce1d01 Make ProcessMemory an abstract interface
Only a Linux implementation for now, but similar code for other
OSes can move behind it in the future.

Bug: crashpad:196
Change-Id: I05966db1599a9cac3146d2a3d964e7ad8629d616
Reviewed-on: https://chromium-review.googlesource.com/685408
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Dave Bort <dbort@google.com>
2017-10-13 21:45:14 +00:00
Mark Mentovai
a327c86a52 C++14 is required, don’t pretend to support pre-C++11 or pre-MSVS 2015
Change-Id: Ide835421599480acc63e8e88ce2217433c0d376e
Reviewed-on: https://chromium-review.googlesource.com/719036
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-10-13 15:49:59 +00:00
Mark Mentovai
7a849482ea Switch the language standard to C++14 and use std::make_unique
Update mini_chromium to 7d6697ceb5cb5ca02fde3813496f48b9b1d76d0c

47ff9691450e Switch the language standard to C++14
7d6697ceb5cb Remove base/memory/ptr_util.h and base::WrapUnique

base::WrapUnique and std::make_unique are similar, but the latter is
standardized and preferred.

Most of the mechanical changes were made with this sed:

for f in $(git grep -l base::WrapUnique | uniq); do
  sed -E \
      -e 's%base::WrapUnique\(new ([^(]+)\((.*)\)\);%std::make_unique<\1>(\2);%g' \
      -e 's%base::WrapUnique\(new ([^(]+)\);%std::make_unique<\1>();%g' \
      -e 's%^#include "base/memory/ptr_util.h"$%#include <memory>%' \
      -i '' "${f}"
done

Several uses of base::WrapUnique that did not fit on a single line and
were not matched by this sed were adjusted manually. All #include
changes were audited manually, to at least move <memory> into the
correct section. Where <memory> was already #included by a file (or its
corresponding header), the extra #include was removed. Where <memory>
should have been #included by a header, it was added. Other similar
adjustments to other #includes were also made.

Change-Id: Id4e0baad8b3652646bede4c3f30f41fcabfdbd4f
Reviewed-on: https://chromium-review.googlesource.com/714658
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-10-12 19:07:13 +00:00
Dave Bort
fe4b16fe88 Move linux/process files to util/process
A step towards making these files usable by non-Linux systems.

Bug: crashpad:196
Change-Id: I71323b29e46208b3992055722e4622d79409c44c
Reviewed-on: https://chromium-review.googlesource.com/685406
Commit-Queue: Dave Bort <dbort@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-10 18:25:07 +00:00
Mark Mentovai
93c88d87f0 win: Don’t appear to be a client connecting in end_to_end_test.py
end_to_end_test.py was producing these error messages 6 times (32-bit
x86) and 7 times (x86_64) per run:

[pid:tid:yyyymmdd,hhmmss.mmm:ERROR file_io.cc:89] ReadExactly: expected
36, observed 0

These messages were being produced by crashpad_handler, in the
LoggingReadFileExactly() call in
ExceptionHandlerServer::ServiceClientConnection().
sizeof(ClientToServerMessage) is 36. crashpad_handler believed that a
client was connecting, but the client sent no data.

This was tracked down to the use of os.path.exists() in
end_to_end_test.py to wait for crashpad_handler’s named pipe to be
created. Checking named pipe existence in this way appeared to be a
client connecting to the the pipe server in crashpad_handler, although
of course no real client was connecting and no message was forthcoming.
I found that running “dir” on the named pipe’s path produced the same
result.

Using WaitNamedPipe() is an alternative that can be used to signal when
the named pipe’s path exists. Furthermore, it tests more than mere
creation, it indicates that the pipe server has become ready to service
clients. That’s not necessary in this case as proper clients already
need to deal with this on their own, but checking it in
end_to_end_test.py should be harmless.

Test: end_to_end_test.py
Change-Id: Ida29a3d2325368f58930cdf8fb053449f621ea52
Reviewed-on: https://chromium-review.googlesource.com/703276
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-10-05 20:58:59 +00:00
Mark Mentovai
e5896de993 win: Fix process_structs.h definition of RTL_USER_PROCESS_PARAMETERS
In the 64-bit version of the structure, padding is needed between
ShowWindowFlags and WindowTitle.

The CurrentDirectores (yes, that’s how it’s spelled) members would have
been interpreted incorrectly because STRING was defined incorrectly. The
length fields are USHORT, not DWORD. In the 64-bit version of the
structure, a padding member ensured that the structure was at least the
correct size. In the 32-bit version of the structure, this caused the
structure size to be inflated, so all but the first CurrentDirectores
element and any struct member that followed would appear at incorrect
offsets, and the overall struct size being read was larger than
appropriate.

This resolves crashpad_handler logging (usually) three errors while
handling a 64-bit process crash, such as:

[pid:tid:yyyymmdd,hhmmss.mmm:ERROR process_info.cc:632] range at
0x780f24de00000000, size 0x275 fully unreadable
[pid:tid:yyyymmdd,hhmmss.mmm:ERROR process_info.cc:632] range at
0x780f24fe00000000, size 0x275 fully unreadable
[pid:tid:yyyymmdd,hhmmss.mmm:ERROR process_info.cc:632] range at 0x0,
size 0x275 fully unreadable

Bug: crashpad:198
Test: end_to_end_test.py
Change-Id: I1655101de01cf46b4b50eda45a11f8d0f3bca8b3
Reviewed-on: https://chromium-review.googlesource.com/701736
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-10-05 20:49:08 +00:00
Mark Mentovai
90054edf62 win: De-flake hanging_program.exe
hanging_program.exe is used by crash_other_program.exe, which is in turn
used by end_to_end_test.py. It hangs by loading loader_lock_dll.dll,
which squats in its entry point function while the loader lock is held.

hanging_program.exe needs to do some work in its Thread1() before the
loader lock is taken (a SetThreadPriority() call), and needs to do some
work in its main thread once the loader lock is held (it needs to signal
crash_other_program.exe that it’s successfully wedged itself).
Previously, proper synchronization was not provided. A 1-second Sleep()
was used to wait for the loader lock to be taken. Thread1() pre-work was
only achieved before the loader lock was taken by sheer luck. Things
didn’t always work out so nicely.

This uses an event handle to provide synchronization. An environment
variable is used to pass the handle to loader_lock_dll.dll, because
there aren’t many better options available. This eliminates both flake
and the unnecessary 1-second delay in hanging_program.exe, and since
this program runs twice during end_to_end_test.py, it improves that
test’s runtime by 2 seconds.

Bug: crashpad:197
Test: end_to_end_test.py
Change-Id: Ib9883215ef96bed7571464cc68e09b6ab6310ae6
Reviewed-on: https://chromium-review.googlesource.com/700076
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-10-04 19:58:56 +00:00
Dave Bort
6c9bd10a24 Use generic VM types in snapshot/elf
A step towards making these files usable by non-Linux systems.

Bug: crashpad:196
Change-Id: I2497fd7e3bcb5390ae1e6ae22902ab6f56b59dff
Reviewed-on: https://chromium-review.googlesource.com/685405
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Dave Bort <dbort@google.com>
2017-10-03 00:42:39 +00:00
Dave Bort
9e07a7148c Move linux/elf files to snapshot/elf
A step towards making these files usable by non-Linux systems.

Bug: crashpad:196
Change-Id: I1dc4304b1376a3a5e45228cf40b23f0367d3efa8
Reviewed-on: https://chromium-review.googlesource.com/685404
Commit-Queue: Dave Bort <dbort@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-02 21:54:34 +00:00
Dave Bort
a04edfad5c Accept a non-empty vdso name in linux/debug_rendezvous_test
Some versions of glibc (e.g., Debian GLIBC 2.24-11+deb9u1) do set a name
for the vdso mapping.

Change-Id: I342a55e95f649d5aaf1e35f1afab53d89f4ba0fc
Reviewed-on: https://chromium-review.googlesource.com/679858
Commit-Queue: Dave Bort <dbort@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-09-25 22:47:44 +00:00
Joshua Peraza
59c5d848e5 linux: Refactor ptrace usage.
1) Add PtraceConnection which serves as the base class for specific
types of connections Crashpad uses to trace processes.
2) Add DirectPtraceConnection which is used when the handler process
has `ptrace` capabilities for the target process.
3) Move `ptrace` logic into Ptracer. This class isolates `ptrace` call
logic for use by various PtraceConnection implementations.

Bug: crashpad:30
Change-Id: I98083134a9f7d9f085e4cc816d2b85ffd6d73162
Reviewed-on: https://chromium-review.googlesource.com/671659
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-09-22 16:25:32 +00:00
Dave Bort
be7b8a509c Include stddef.h for offsetof() in cpuid_reader.cc
Fixes the build for x86_64-linux-gnu-g++-6 6.3.0 20170516
on a recent Debian Testing system [Debian GNU/Linux 9.0 (stretch)].

Change-Id: Ibaa7b314723d41259703d723cbdd326982aaf159
Reviewed-on: https://chromium-review.googlesource.com/675576
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
Commit-Queue: Dave Bort <dbort@google.com>
2017-09-21 21:39:25 +00:00
Joshua Peraza
b953388b95 Add SystemSnapshotLinux
Bug: crashpad:30
Change-Id: Ic1162c6637708492a5a9903a221cdd9266d3fd97
Reviewed-on: https://chromium-review.googlesource.com/601028
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-08-08 22:31:46 +00:00
Xi Cheng
01110c0a3b win: Fix %u, %d, %x/DWORD printf mismatches
To enable clang-cl's printf format string mismatch checking, a few
mismatch errors need to be fixed where DWORD (unsigned long) is printed
with %u, %d or %x (an 'l' is needed).

Change-Id: I2cbfafe823a186bfe3a555aec3a7ca03e85466f8
Reviewed-on: https://chromium-review.googlesource.com/598651
Commit-Queue: Xi Cheng <chengx@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-08-02 22:04:13 +00:00
Joshua Peraza
edf4dde8ae linux: Add ExceptionSnapshotLinux
Bug: crashpad:30
Change-Id: I450d53a89af2995c0fd13b31821360e781fe015a
Reviewed-on: https://chromium-review.googlesource.com/589747
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-08-02 02:29:51 +00:00
Mark Mentovai
7f038ebbd2 #include "build/build_config.h" where necessary
Change-Id: Ifd58969ca39a2fda5d2bcf34c6442158548ad2ab
Reviewed-on: https://chromium-review.googlesource.com/593148
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-07-31 16:53:14 +00:00
Mark Mentovai
3a5837c773 #include "build/build_config.h" where necessary
Change-Id: I982ec4f7a87fa92925d22267f948df6ca5febea7
Reviewed-on: https://chromium-review.googlesource.com/592693
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-07-29 21:11:31 +00:00
Mark Mentovai
8f0636288a Use constexpr at namespace scope
This is essentially based on a search for “^const .*=”.

Change-Id: I9332c1f0cf7c891ba1ae373dc537f700f9a1d956
Reviewed-on: https://chromium-review.googlesource.com/585452
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-07-29 01:06:52 +00:00
Mark Mentovai
6dac7ecdf5 Use constexpr at function scope
This is essentially based on a search for “^ *const [^*&]*=[^(]*$”

Change-Id: Id571119d0b9a64c6f387eccd51cea7c9eb530e13
Reviewed-on: https://chromium-review.googlesource.com/585555
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-07-29 00:50:40 +00:00
Mark Mentovai
281be63d00 Standardize on static constexpr for arrays when possible
This uses “static” at function scope to avoid making local copies, even
in cases where the compiler can’t see that the local copy is
unnecessary. “constexpr” adds additional safety in that it prevents
global state from being initialized from any runtime dependencies, which
would be undesirable.

At namespace scope, “constexpr” is also used where appropriate.

For the most part, this was a mechanical transformation for things
matching '(^| )const [^=]*\['.

Similar transformations could be applied to non-arrays in some cases,
but there’s limited practical impact in most non-array cases relative to
arrays, there are far more use sites, and much more manual intervention
would be required.

Change-Id: I3513b739ee8b0be026f8285475cddc5f9cc81152
Reviewed-on: https://chromium-review.googlesource.com/583997
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-07-25 17:40:51 +00:00
Joshua Peraza
01b347732e linux: Collect CPU times in ProcStatReader and use in ProcessReader
Bug: crashpad:30
Change-Id: I6d4020220031670937acad12d0b7878c1ae0fae7
Reviewed-on: https://chromium-review.googlesource.com/583952
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-25 04:15:32 +00:00
Joshua Peraza
37f20f7b14 Add ThreadSnapshotLinux
Bug: crashpad:30
Change-Id: Iee8eaecadc4b8d61d3975a79fbc7f80dbb39a134
Reviewed-on: https://chromium-review.googlesource.com/580207
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-20 19:55:21 +00:00
Joshua Peraza
bde35ca918 Add MemorySnapshotLinux
Bug: crashpad:30
Change-Id: Iddd100c3806178f6d20dd903e3f41926904696d4
Reviewed-on: https://chromium-review.googlesource.com/577977
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-20 18:45:12 +00:00
Joshua Peraza
7be6b8ea1d Add functions to convert native x86 contexts to Crashpad CPUContexts
Debug registers are currently initialized to 0 until methods are added
to ThreadInfo to collect them.

Bug: crashpad:30
Change-Id: Ic1aab1151dcd4bed48eca8a60b76fb0d8d613418
Reviewed-on: https://chromium-review.googlesource.com/579889
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-20 18:16:11 +00:00
Joshua Peraza
6b5f139d88 linux: Add ProcessReader
ProcessReader is responsible for collecting information needed to build
a snapshot of the target process, independent of the Snapshot
interface. This CL includes implementation and tests for collecting
thread information, but does not yet collect module information.

Bug: crashpad:30
Change-Id: I911f155c953129a5fa8c031e923c0de2bd740ce0
Reviewed-on: https://chromium-review.googlesource.com/488162
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-19 18:16:09 +00:00
Mark Mentovai
6ab73e0ad8 linux: #include appropriate headers for ElfImageReader
Bug: crashpad:30
Change-Id: I749a3493ec6a76dac904b36676330c5e487f356d
Reviewed-on: https://chromium-review.googlesource.com/571956
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-07-14 20:24:25 +00:00
Joshua Peraza
041a50d75c linux: Add DebugRendezvous to read dynamic linker data structures
Dynamic linkers use `struct r_debug` and `struct link_map` (defined in
`<link.h>`) to communicate lists of loaded modules to debuggers.

Bug: crashpad:30
Change-Id: Id903a1c199288dd85c34e38710cdb4c6b5fedb5b
Reviewed-on: https://chromium-review.googlesource.com/534853
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-14 19:07:05 +00:00
Joshua Peraza
a79791969d linux: Add MemoryMap::FindFileMmapStart
ELF executables and libraries may be loaded into memory in several
mappings, possibly with holes containing anonymous mappings
or mappings of other files. This method takes an input mapping and
attempts to find the mapping for file offset 0 of the same file.

Bug: crashpad:30
Change-Id: I79abf060b015d58ef0eba54a399a74315d7d2d77
Reviewed-on: https://chromium-review.googlesource.com/565223
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-11 16:19:48 +00:00
Joshua Peraza
4224be41d7 linux: Add ElfImageReader to read ELF images via ProcessMemory
Bug: crashpad:30
Change-Id: Id2a6a1868103b0f4374816e58aab365a977b010d
Reviewed-on: https://chromium-review.googlesource.com/508836
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2017-07-06 16:51:29 +00:00
Mark Mentovai
f37b382687 linux/android: Reenable util test, and enable snapshot test
107fb7631788 added the snapshot library as a dependency of
crashpad_util_test. Most of snapshot has not yet been ported to Linux or
Android. snapshot/capture_memory.cc only supports x86 and x86_64, and
will #error on other CPUs. We don’t build for other CPUs on Mac or
Windows, but we do for Android.

To make it easy to run crashpad_util_test on non-x86 again,
conditionally remove capture_memory.cc on Linux and Android.

crashpad_snapshot_test can be enabled for Linux and Android too by
disabling the CrashpadInfoClientOptions tests which require OS support.
There’s not much left in crashpad_snapshot_test currently for Linux
except for CPUContextX86 and ProcessSnapshotMinidump.EmptyFile, but both
pass.

Bug: crashpad:30
Change-Id: Ic19a79932072710c69a296bc0156cbe5656b8cb3
Reviewed-on: https://chromium-review.googlesource.com/549116
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-06-27 14:23:14 +00:00
Mark Mentovai
890ad441b3 mac: Accept modules in 10.13’s dyld shared cache
In 10.13, modules loaded from the dyld shared cache appear with __TEXT
segments that have a nonzero “fileoff” (file offset). Previously, the
fileoff was always 0. Previously, the fileoff for segments in the dyld
shared cache was the actual offset into the shared cache (not 0), but
special consideration was given to __TEXT segments which were forced to
0. See 10.12.4 dyld-433.5/interlinked-dylibs/OptimizerLinkedit.cpp
LinkeditOptimizer<>::updateLoadCommands(). Note the comment there where
the __TEXT segment’s apparent fileoff is set to 0:

// HACK until lldb fixed in: <rdar://problem/20357466>
// DynamicLoaderMacOSXDYLD fixes for Monarch dyld shared cache

Refer also to the lldb commit that references the above,
http://llvm.org/viewvc/llvm-project?view=revision&revision=233714.

Evidently, update_dyld_shared_cache has been revised to no longer apply
this hack in 10.13. Crashpad’s sanity check for __TEXT segments having a
fileoff of 0 is no longer valid, and causes it to reject modules loaded
from the dyld shared cache.

Since this was just a sanity check, remove it entirely.

This caused module information for modules loaded from the dyld shared
cache to be missing from minidumps produced on 10.13, which in turn
prevented symbolization in frames belonging to most system libraries.
For reasons not yet understood, I don’t see this problem in Chrome on
10.13db1 17A264c on a test virtual machine (HFS+ filesystem), although I
do see it on actual hardware (APFS filesystem), and I do see it in
Crashpad’s tests and reduced testcases on both as well.

Bug: crashpad:185, crashpad:189
Test: crashpad_snapshot_test MachOImageReader.Self_DyldImages:ProcessReader.SelfModules:ProcessReader.ChildModules:ProcessTypes.DyldImagesSelf
Change-Id: I8b0a22c55c33ce920804a879f6fab67272f3556e
Reviewed-on: https://chromium-review.googlesource.com/535576
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-06-14 19:49:44 +00:00
Mark Mentovai
6108d25232 mac: Update the process_types version of dyld_all_image_infos for 10.13
10.13 introduces two new fields to dyld_all_image_infos. Oddly, it
doesn’t put them in the “reserved” area that was defined in this
structure. This addition made it necessary for the padding problem in
the 32-bit structure previously worked around in Crashpad to be
addressed in the native structure, so Crashpad’s definition is adapted
to match.

This fixes tests on 10.13 that verify that dyld_all_image_infos can be
interpreted correctly.

Note that although the 10.13 SDK includes this structure extension,
numbered version 16, 10.13db1 17A264c continues to use version 15 as
used on 10.12, at least in crashpad_snapshot_test.

Bug: crashpad:185
Test: crashpad_snapshot_test ProcessTypes.DyldImagesSelf
Change-Id: I59a80c85bb234ef698c65a0ac5bbeac5b40fda77
Reviewed-on: https://chromium-review.googlesource.com/535394
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-06-14 18:44:17 +00:00
Mark Mentovai
107fb76317 mac: Handle _dyld_get_all_image_infos() not being available on 10.13
_dyld_get_all_image_infos() was only used in test code in Crashpad.

This addresses two related problems.

When running on 10.13 or later, _dyld_get_all_image_infos() is not
available. It appears to still be implemented in dyld, but its symbol is
now private. This was always known to be an “internal” interface. When
it’s not available, fall back to obtaining the address of the process’
dyld_all_image_infos structure by calling task_info(…, TASK_DYLD_INFO,
…). Note that this is the same thing that the code being tested does,
although the tests are not rendered entirely pointless because the code
being tested consumes dyld_all_image_infos through its own
implementation of an out-of-process reader interface, while the
dyld_all_image_infos data obtained by _dyld_get_all_image_infos() is
handled strictly in-process by ordinary memory reads. This is covered by
bug 187.

When building with the 10.13 SDK, no _dyld_get_all_image_infos symbol is
available to link against. In this case, access the symbol strictly at
runtime via dlopen() if it may be available, or when expecting to only
run on 10.13 and later, don’t even bother looking for this symbol. This
is covered by part of bug 188.

Bug: crashpad:185, crashpad:187, crashpad:188
Change-Id: Ib283e070faf5d1ec35deee420213b53ec24fb1d3
Reviewed-on: https://chromium-review.googlesource.com/534633
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-06-14 15:08:05 +00:00
Mark Mentovai
2851e5cfc8 mac: Update cl_kernels workaround for macOS 10.13 (and later)
Since Apple closed https://openradar.appspot.com/20239912 without fixing
anything, it looks like we’ll be stuck with these quriky cl_kernels
modules for quite some time. Allow these modules to be tolerated on any
OS version >= 10.10, where they first appeared in a broken state, by
removing the upper bound for the OS version to tolerate with this quirk.

The tolerance was previously expanded to include 10.11 in
cd1f8fa3d2f2c76802952beac71ad85f51bbf771 and 10.12 in
6fe7c5414e46acfa30e8984513bf0896e91b9407. After this third update, this
should hopefully no longer be an annual exercise.

Bug: crashpad:185, crashpad:186
Change-Id: I66d409f2d1638bcf7601b6622f000be245230f34
Reviewed-on: https://chromium-review.googlesource.com/534253
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-06-13 19:47:59 +00:00
Mark Mentovai
15103742e0 Use FromPointerCast<>() in many places where it makes sense
I opted to leave casts to types that were definitely the same size
alone. reinterpret_cast<uintptr_t>(pointer) and
reinterpret_cast<intptr_t>(pointer) should always be safe, for example.
Casts to other integral types have been replaced with
FromPointerCast<>(), which does zero-extension or sign-extension based
on the target type.

To make it possible to use FromPointerCast<>() with some use sites that
were already using checked_cast<>(), FromPointerCast<>() now uses
check_cast<>() when converting to a narrower type.

Test: crashpad_util_test FromPointerCast*, others
Change-Id: I4a71b4aa2d87f545c75524290a702f5f3138d675
Reviewed-on: https://chromium-review.googlesource.com/489701
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-05-01 15:54:00 +00:00
Mark Mentovai
fd8e2de0c5 win: MSVS 2017 (15)/C++ 14.1/C 19.10 compatibility
Includes mini_chromium ef0ded8717340c9fe48e8e0f34f3e0e74d10a392.

1d2a024fdb1d android: Use _FILE_OFFSET_BITS after all (undo
             dc3d480305b2)
ef0ded871734 win: MSVS 2017 (15)/C++ 14.1/C 19.10 compatibility

Change-Id: I5c814669a0ef8577872bddff9112ce28ec628ba3
Reviewed-on: https://chromium-review.googlesource.com/482639
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-20 00:28:35 +00:00
Mark Mentovai
74fddc3fed win: Wrap test::ChildLauncher::Start() in ASSERT_NO_FATAL_FAILURE()
Test: crashpad_snapshot_test, crashpad_util_test, end_to_end_test
Change-Id: I09581521678fe3b083c409f308eeab2e583b3c9f
Reviewed-on: https://chromium-review.googlesource.com/481245
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-19 17:47:23 +00:00
Mark Mentovai
79425e4d97 win: Free an old buffer before attempting to allocate a resized one
When GetProcessInformation() obtains SystemProcessInformation, it
resizes its buffer as directed by NtQuerySystemInformation(). Nothing of
value resides in the old buffer if a resize is attempted, so it can be
freed before attempting to allocate a resized one.

This may help crashes like go/crash/f385e94c80000000, which experience
out-of-memory while attempting to allocate a resized buffer. It also may
not help, because the required buffer size may just be too large to fit
in memory. See https://crashpad.chromium.org/bug/143#c19.

Change-Id: I63b9b8c1efda22d2fdbf05ef2b74975b92556bbd
Reviewed-on: https://chromium-review.googlesource.com/473792
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-11 21:49:46 +00:00
Joshua Peraza
45305395ad win: Determine length of unloaded module names
Change-Id: I802b2a8a505cf53009c0c5648acdad7a44e9f0e7
Reviewed-on: https://chromium-review.googlesource.com/466598
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-04-04 17:15:39 +00:00
Mark Mentovai
4b450c8137 test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.

This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.

EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.

References:

https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
77d6b17338
https://github.com/google/googletest/pull/713

Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 12:34:24 +00:00
Mark Mentovai
4688351623 “Promote” test::Paths::Executable() to Paths::Executable()
This supports the “double handler” or “double handler with low
probability” models from https://crashpad.chromium.org/bug/143.

For crashpad_handler to be become its own client, it needs access to its
own executable path to pass to CrashpadClient::StartHandler(). This was
formerly available in the test-only test::Paths::Executable(). Bring
that function’s implementation to the non-test Paths::Executable() in
util/misc, and rename test::Paths to test::TestPaths to avoid future
confusion.

test::TestPaths must still be used to access TestDataRoot(), which does
not make any sense to non-test code.

test::TestPaths::Executable() is retained for use by tests, which most
likely prefer the fatal semantics of that function. Paths::Executable()
is not fatal because for the purposes of implementing the double
handler, a failure to locate the executable path (which may happen on
some systems in deeply-nested directory hierarchies) shouldn’t cause the
initial crashpad_handler to abort, even if it does prevent a second
crashpad_handler from being started.

Bug: crashpad:143
Test: crashpad_util_test Paths.*, crashpad_test_test TestPaths.*
Change-Id: I9f75bf61839ce51e33c9f7c0d7031cebead6a156
Reviewed-on: https://chromium-review.googlesource.com/466346
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-04-03 18:58:01 +00:00
Mark Mentovai
d6837b2b86 mac: Fix SystemSnapshotMacTest.TimeZone on macOS 10.12.4
macOS 10.12.4 includes an updated timezone database. Abbreviations for
Australia/Eucla (formerly ACWST, now +0845) and Australia/Lord_Howe
(formerly LHST/LHDT, now +1030/+11) were dropped in IANA TZ 2017a. The
test is updated so that the abbreviations for these two time zones are
no longer checked.

References:
a25d615495
https://mm.icann.org/pipermail/tz/2017-February/024837.html

Test: crashpad_snapshot_test SystemSnapshotMacTest.TimeZone
Change-Id: I2845c6aee7b7b6a8fcdc6faa4d5cefe5e0f72e5c
Reviewed-on: https://chromium-review.googlesource.com/461500
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-03-28 18:20:28 +00:00
Mark Mentovai
f14eda221f win: Be more careful about exit codes in end_to_end_test.py
This is like 270490ff79df, but for things run by end_to_end_test.py, and
things run for it by crash_other_program.exe.

Change-Id: Iabf3c762c50f41eb61ab31f714c646364196e745
Reviewed-on: https://chromium-review.googlesource.com/458822
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-03-24 22:34:48 +00:00
Mark Mentovai
6c8a3f7007 win: Use a semaphore for synchronization in ProcessSnapshotTest
Bug: crashpad:160
Test: crashpad_snapshot_test ProcessSnapshotTest.CrashpadInfoChild*
Change-Id: Id9bd1ee6ec71c57ecab2ccba6106d41446d66902
Reviewed-on: https://chromium-review.googlesource.com/458879
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-03-24 21:54:17 +00:00
Mark Mentovai
270490ff79 win: Be more careful about child process exit codes
Checking child process’ exit codes would have helped catch bug
crashpad:160 sooner. Instead, we had a flaky hang that was difficult to
reproduce locally.

Bug: crashpad:160
Test: crashpad_snapshot_test ExceptionSnapshotWinTest.ChildCrash*:ProcessSnapshotTest.CrashpadInfoChild*:SimulateCrash.ChildDumpWithoutCrashing*, crashpad_util_test ProcessInfo.OtherProcess
Change-Id: I73bd2be1437d05f0501a146dcb9efbe3b8e0f8b7
Reviewed-on: https://chromium-review.googlesource.com/459039
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-03-24 20:12:31 +00:00
Scott Graham
9104d53d1c Fix thread startup in snapshot reader test
The use of InterlockedCompareExchange() was very wrong. Improved error
checking coming in another CL from mark@, see linked bug for discussion.

Bug: crashpad:160
Change-Id: Id230af6f37c6cdce807dd4d8aba9d33e9bdeffd0
Reviewed-on: https://chromium-review.googlesource.com/459230
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-24 19:32:04 +00:00
Mark Mentovai
013d5e14a3 #include <stddef.h> where offsetof() is used
Bug: crashpad:30
Change-Id: If23ca9ea3141d3d34dc494aa29a1bd1dc8f83130
Reviewed-on: https://chromium-review.googlesource.com/458079
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-03-23 02:15:32 +00:00
Mark Mentovai
e4cad9e514 doc: Standardize on “macOS” in comments
952f787f4aab missed two occurrences that should have been updated.

Change-Id: I425367689eb19edfd309a2210a79ed400e190673
Reviewed-on: https://chromium-review.googlesource.com/458116
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-03-22 17:26:14 +00:00
Mark Mentovai
14138936b5 test: Compare ProcessInfo::Arguments() to main()’s argc/argv on POSIX
Previously on macOS, the test used an OS-specific library function to
recover the original argc and argv. On Linux/Android, it essentially
reimplemented the very code it was testing, which didn’t make for a very
good test. The new approach is to save argc and argv in main() and base
the comparison on that.

Bug: crashpad:30
Test: crashpad_util_test ProcessInfo.*, crashpad_test_test MainArguments.*
Change-Id: I578abed3b04ae10a22f79a193bbb8b6589276c97
Reviewed-on: https://chromium-review.googlesource.com/456798
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-03-20 17:05:30 +00:00
Mark Mentovai
00b6442752 Make file_io reads more rational and predictable
ReadFile() attempted to continue reading after a short read. In most
cases, this is fine. However, ReadFile() would keep trying to fill a
partially-filled buffer until experiencing a 0-length read(), signaling
end-of-file. For certain weird file descriptors like terminal input, EOF
is an ephemeral condition, and attempting to read beyond EOF doesn’t
actually return 0 (EOF) provided that they remain open, it will block
waiting for more input. Consequently, ReadFile() and anything based on
ReadFile() had an undocumented and quirky interface, which was that any
short read that it returned (not an underlying short read) actually
indicated EOF.

This facet of ReadFile() was unexpected, so it’s being removed. The new
behavior is that ReadFile() will return an underlying short read. The
behavior of FileReaderInterface::Read() is updated in accordance with
this change.

Upon experiencing a short read, the caller can determine the best
action. Most callers were already prepared for this behavior. Outside of
util/file, only crashpad_database_util properly implemented EOF
detection according to previous semantics, and adapting it to new
semantics is trivial.

Callers who require an exact-length read can use the new
ReadFileExactly(), or the newly renamed LoggingReadFileExactly() or
CheckedReadFileExactly(). These functions will retry following a short
read. The renamed functions were previously called LoggingReadFile() and
CheckedReadFile(), but those names implied that they were simply
wrapping ReadFile(), which is not the case. They wrapped ReadFile() and
further, insisted on a full read. Since ReadFile()’s semantics are now
changing but these functions’ are not, they’re now even more distinct
from ReadFile(), and must be renamed to avoid confusion.

Test: *
Change-Id: I06b77e0d6ad8719bd2eb67dab93a8740542dd908
Reviewed-on: https://chromium-review.googlesource.com/456676
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-03-16 20:07:43 +00:00
Mark Mentovai
9be4745be0 linux: Lazily initialize ProcessInfo’s Is64Bit() and StartTime()
Lazy initialization is particularly beneficial for Is64Bit(), which uses
a different (ptrace()-based) approach than the rest of the class (which
is /proc-based). It is possible for the /proc-based Initialize() to
succeed while ptrace() would fail, as it typically would in the
ProcessInfo.Pid1 test. Because this test does not call Is64Bit(),
permission to ptrace() shouldn’t be necessary, and in fact ptrace()
shouldn’t even be called.

This enables the ProcessInfo.Pid1 test on Android (due to ptrace(), it
was actually failing on any Linux, not just Android). It also enables
the ProcessInfo.Forked test on non-Linux, as the prctl(PR_SET_DUMPABLE)
Linux-ism can be removed from it.

Bug: crashpad:30
Test: crashpad_util_test ProcessInfo.*
Change-Id: Ic883733a6aed7e7de9a0f070a5a3544126c7e976
Reviewed-on: https://chromium-review.googlesource.com/455656
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-03-15 16:01:27 +00:00
Mark Mentovai
8e82f6fde0 mac: Update test and comments with feedback from Apple bug
Apple has responded to their bug 29079442 with a resolution stating that
these are not corpse ports but task ports that have changed after
execve(), as part of the large task port and execve() strategy rewrite
from 10.12.1. The comments being replaced were written before we had
10.12.1 source code. Now that we can see what’s going on, revise the
comments, and re-enable the task port check for the non-execve() test
variants.

https://openradar.appspot.com/29079442
https://googleprojectzero.blogspot.com/2016/10/taskt-considered-harmful.html

Bug: crashpad:137
Test: crashpad_snapshot_test MachOImageAnnotationsReader.CrashDyld
Change-Id: I463637816085f4165b92b85a5b98bfeddcdf4094
Reviewed-on: https://chromium-review.googlesource.com/451120
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-03-08 00:35:54 +00:00
Mark Mentovai
9660a1b66e win: Fix build after 60be5a66a050
crashpad_util should already have been the target to depend on
version.lib, but this wasn’t caught until something that depends on
crashpad_util but not crashpad_snapshot used that code, as
crashpad_util_test now does.

Change-Id: I1b7ced72c657946b297a328c0f89f51190d7d708
Reviewed-on: https://chromium-review.googlesource.com/448203
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-03-01 19:32:52 +00:00
Mark Mentovai
60be5a66a0 net: Provide better HTTP User-Agent strings
Previously, macOS used “User-Agent: crashpad_util_test (unknown version)
CFNetwork/807.2.14 Darwin/16.4.0 (x86_64)” and Windows gave results like
“User-Agent: Crashpad/0.8.0”.

Now, macOS uses “User-Agent: Crashpad/0.8.0 CFNetwork/807.2.14
Darwin/16.4.0 (x86_64)” and Windows uses “User-Agent: Crashpad/0.8.0
WinHTTP/10.0.14393.351 Windows_NT/10.0.14393.0 (x64)”

Change-Id: I578b44734cf59d79e3d9b6136b4b92f05acefe71
Reviewed-on: https://chromium-review.googlesource.com/447796
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-03-01 17:44:08 +00:00
Mark Mentovai
6da9708e7c doc: Fix Doxygen errors
Change-Id: I5d5abf7b7eabe269a7c7b4d305a67fe910c887fd
Reviewed-on: https://chromium-review.googlesource.com/446480
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-23 01:43:40 +00:00
Mark Mentovai
546e64cd0b Centrally define CPUContextX86::Fsave and fsave↔︎fxsave conversions
As I was finishing d98a4de718d9, it became evident that fsave
proliferation was becoming a problem. Especially considering tests,
there was much duplicated conversion code. This ties everything up
together in a central location.

test::BytesToHexString() is a new function to ease testing of byte
arrays like x87 registers, without having to loop over each byte.

Some static_asserts are added to verify that complex structures that
need to maintain interoperability don’t grow or shrink. This is used
to check the size of the fxsave and fsave structures, as well as the
MinidumpCPUContext* structures.

BUG=crashpad:162

Change-Id: I1a1be18096ee9be250cbfb2e006adfd08eba8753
Reviewed-on: https://chromium-review.googlesource.com/444004
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-16 18:26:13 +00:00
Mark Mentovai
d98a4de718 win: support native x86 CONTEXT structures with x87 but no SSE context
When no SSE (fxsave) context is available but x87 (fsave) context is, use the
x87 context.

This also embeds the x87 FPU opcode from the fxsave fop field in bits 16-26 of
the fsave error_selector field, true to the layout of the fsave structure. See
Intel SDM volume 1 (253665-061) 8.1.10 and figure 8-9.

BUG=crashpad:161
TEST=crashpad_snapshot_test CPUContextX86.*:CPUContextWin.*

Change-Id: I0bf7ed995c152f124166eaa20104d228d3468f76
Reviewed-on: https://chromium-review.googlesource.com/442144
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-15 17:39:50 +00:00
Mark Mentovai
88442dd578 Merge Chromium 294442c0ce05 upstream to Crashpad
Remove stl_util from Crashpad. This also updates mini_chromium to
4f3cfc8e7c2b7d77f94f41a32c3ec84a6920f05d to remove stl_util from there
as well.

4f3cfc8e7c2b Remove stl_util from mini_chromium

BUG=chromium:555865

Change-Id: I8ecb1639a258dd233d524834ed205a4fcc641bac
Reviewed-on: https://chromium-review.googlesource.com/438865
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-07 21:04:42 +00:00
Mark Mentovai
b638163e72 Report time zones with no DST transition within a year as not observing
In locations where daylight saving time was once observed or is expected
to be observed in the future, but where no transitions to or from
daylight saving time occurred or will occur within a year of the current
date, act as though DST is not being observed at all.

Set TZ=America/Phoenix to test for this bug.

BUG=crashpad:130
TEST=crashpad_snapshot_test SystemSnapshotMacTest.TimeZone

Change-Id: Ie466b5906eab3c0cf2e51b962a171acb5b16210b
Reviewed-on: https://chromium-review.googlesource.com/438004
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-07 19:00:44 +00:00
Mark Mentovai
594eb43b58 mac: Make 64-bit handler able to read 32-bit module lists
The 32-bit process_types definition of dyld_all_image_infos winds up
with four extra bytes of tail padding when built into a 64-bit
crashpad_handler compared to a 32-bit one, and compared to the
structure’s native size. This prevents a 64-bit crashpad_handler from
being able to create a module snapshot of a 32-bit process for
dyld_all_image_infos versions 14 (since 10.9) and 15 (since 10.12).

Work around this by placing a zero-length “end” marker and using
offsetof(dyld_all_image_infos, end) in preference to
sizeof(dyld_all_image_infos).

BUG=crashpad:156,crashpad:148,crashpad:120
TEST=crashpad_snapshot_test ProcessTypes.DyldImagesSelf,
     run_with_crashpad --handler=crashpad_handler{,32} builtin_trap{,32}

Change-Id: I406ad53851b5bd29ec802b7ad3073836ebe8c34c
Reviewed-on: https://chromium-review.googlesource.com/437924
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-07 18:58:39 +00:00
Mark Mentovai
e7630628e9 mac: Report richer exception codes via metrics
Previously, only the top-level exception code was reported via the
Crashpad.ExceptionCode.Mac histogram. Making this histogram work
(https://crbug.com/678720) has revealed that Chrome is triggering
EXC_RESOURCE exceptions at a rate in excess of 4x that of ordinary
crashes. These exceptions were not previously visible because they are
not uploaded unless the system treats them as fatal, which it does not
normally do absent an explicit request.

In order to learn more about the problem, this change augments the data
reported via the Crashpad.ExceptionCode.Mac histogram to report (at
least) second-level exception data. This means that we will no longer
see just EXC_RESOURCE, but potentially more useful information such as
EXC_RESOURCE / RESOURCE_TYPE_IO / FLAVOR_IO_PHYSICAL_WRITES. This also
applies to other exception types, so that the majority of crashes
currently falling into the EXC_CRASH bucket will now have additional
information decoded and will be reported as, for example, EXC_BAD_ACCESS
/ KERN_INVALID_ADDRESS, EXC_BAD_INSTRUCTION / EXC_I386_INVOP, and
EXC_CRASH / SIGABRT.

Because the old mechanism was only live (in an “it works” sense) for
several days, and the new mechanism does not overlap with histogram
values used by the old one, there’s no need to invent a new histogram
name.

BUG=chromium:684051

Change-Id: Ia0a372b4127f7b3b2e7dbbaac9304cce3b5aadfe
Reviewed-on: https://chromium-review.googlesource.com/430933
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-01-24 15:59:30 +00:00
Scott Graham
0567536f86 win: Attempt to fix unloaded modules list by using RtlGetUnloadEventTraceEx
I haven't been able to reproduce this locally, but we see errors in
crash dumps where the unloaded module list consists of a number of
modules with invalid names and implausible addresses. My assumption is
that RTL_UNLOAD_EVENT_TRACE isn't correct for some OS levels. Instead of
trying to finesse and test that, use RtlGetUnloadEventTraceEx() instead
of RtlGetUnloadEventTrace(), which returns an element size. (This
function is Vista+ which is why it wasn't used the first time around.)

R=mark@chromium.org
BUG=chromium:620175

Change-Id: I4d7080a03623276f9c1c038d6e7329af70e4a64c
Reviewed-on: https://chromium-review.googlesource.com/421564
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-12-16 20:32:25 +00:00
Scott Graham
8b3eec83e9 win: Add signal handler for SIGABRT to handle abort() calls
R=mark@chromium.org
BUG=crashpad:57

Change-Id: Ib7141f00e74e3db9e5be427cc990847331e09912
Reviewed-on: https://chromium-review.googlesource.com/412058
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-17 22:00:38 +00:00
Mark Mentovai
57b2210ed7 GCC fix: Make UUID POD
This eliminates all constructors, but nearly all points of use were
using the default constructor to initialize a UUID member variable as in
uuid_(). This syntax will still produce a zeroed-out UUID.

While compiling, for example, minidump_rva_list_writer.cc:

In file included from ../../minidump/minidump_rva_list_writer.h:25:0,
                 from ../../minidump/minidump_rva_list_writer.cc:15:
../../minidump/minidump_extensions.h:412:8: error: ignoring packed attribute because of unpacked non-POD field ‘crashpad::UUID crashpad::MinidumpCrashpadInfo::report_id’ [-Werror]
   UUID report_id;
        ^~~~~~~~~
../../minidump/minidump_extensions.h:424:8: error: ignoring packed attribute because of unpacked non-POD field ‘crashpad::UUID crashpad::MinidumpCrashpadInfo::client_id’ [-Werror]
   UUID client_id;
        ^~~~~~~~~

Tested with:
 - GCC 4.9 from NDK r13 targeting arm with SDK 16
 - GCC 4.9 from NDK r13 targeting arm64 with SDK 21
 - GCC 6.2 targeting x86_64

BUG=crashpad:30

Change-Id: Iec6b1557441b69d75246f2f75c59c4158fb7ca29
Reviewed-on: https://chromium-review.googlesource.com/409641
Reviewed-by: Scott Graham <scottmg@chromium.org>
2016-11-11 17:37:14 +00:00