978 Commits

Author SHA1 Message Date
Joshua Peraza
20cbfa4971 linux: Use mmap for attachments in PtraceBroker
The broker attempts to use sbrk() to allocate memory to track ptrace
attachments. If the process failed due to an OOM, this system call might
fail, the broker falls back to saving attachments on the stack, and then
overruns the stack.

This change updates the broker to use sys_mmap() instead of sbrk(),
which is expected to work at least as well. If sys_mmap() fails or
the first mapped page is exhausted, further attachments fail without
attempting to save them to the stack.

Bug: chromium:1128441
Change-Id: Ibffaa986403adaf3178ee77e6d210053fbf60f26
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2488280
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-12-03 23:24:55 +00:00
yucliu
b6f2d06996 [Android] Fix un-paired namespace declare for higher __ANDROID_API__
Bug: None
Test: Build with larger __ANDROID_API__ (29)
Change-Id: I5bfb8ad0ea5b866469191c5a385b071eec185716
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2522110
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
2020-11-05 21:14:26 +00:00
Justin Cohen
d7c2340283 ios: Disable IOSExceptionProcessor SelectorExists.
Disabled while fix is being investigated.

Bug: crashpad:358
Change-Id: Ie7de5ab01b60e6f3e93096980dcdecd1eec1f171
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2505597
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-28 19:20:28 +00:00
Joshua Peraza
88955e6b56 Fix ThreadLogMessagesTest on Chrome OS
Previously, these tests expected a specifically formatted prefix to log
messages, but logging on Chrome OS uses a different format for the
prefix.

This change updates the tests to expect log messages at the end of a log
line, but ignores the prefix.

Change-Id: Iff748eec04d0fc5a0a786a5676a74e2aad1ec243
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2503462
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-10-28 16:22:51 +00:00
Joshua Peraza
68b10080d2 Be more tidy
Change-Id: I9d2b718c36bd1dd7538241e91b984a50039068f3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2502773
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-27 16:40:45 +00:00
Joshua Peraza
cdb1e7f52b fix flake in LogOutputStreamTest
LogOutputStreamTest.{WriteAbort,FlushAbort} are flaky because the logcat
is sometimes overloaded earlier than expected causing FlushAbort to fail
during Write() or either test to fail to write the abort message.

This change updates LogOutputStream to detect logcat overloads (EAGAIN)
and make one attempt at writing the abort message, even if the output
cap hasn't been reached.

This change also updates LogOutputStream's interface to defer log writes
to a Delegate. In tests, the Delegate implements a mock log and in
production, writes to Android's logcat.

I've removed VerifyGuards because LogOutputStream no longer writes
guards if Write() has never been called and the guards are tested in
other tests.

Change-Id: Icad83524aaf573c3e082469f1de095b6ca2c4839
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2439641
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-26 18:36:11 +00:00
Joshua Peraza
5368dc6389 handle potentially throwing functions in no_cfi_icall
Define templates for potentially throwing functions at C++17
when noexcept becomes part of a function's type.

Change-Id: I8e9cbf4b0702ad6b9b9a9d7560418908045fd11a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2454835
Reviewed-by: Eric Astor <epastor@google.com>
2020-10-26 18:11:33 +00:00
Joshua Peraza
79d43b8ac3 Add noexcept to no_cfi_icall templates
Change-Id: I8115406303813c983bb4bb627e3b25adbdb3efee
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2441392
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-02 17:46:48 +00:00
Nico Weber
0e03f8e7fa Remove now-no-op set_sources_assignment_filter calls
After https://chromium-review.googlesource.com/c/chromium/src/+/2426564,
not having a sources assignments filter is the default.

No behavior change.

Bug: chromium:1018739
Change-Id: Ia2e6af0d613d3cbdfe6595bfe1f688c1efd55f39
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2446269
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-02 17:43:39 +00:00
Scott Graham
e6b525a4be Update config adjustments for moved build config in mini_chromium
Includes DEPS roll of mini_chromium:
f0bd14b Pull build_config.h source set into separate build file
65fb5c9 Update path to win_helper after moving to build/config

Change-Id: Ic9f5c68e2cebd8bf86492766684bdb422da1aa9e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2426989
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-23 22:12:16 +00:00
Eric Astor
865ba27672 Remove unnecessary macro from CaptureContext code
The Windows implementation of CaptureContext used a macro to refer to
the offset of a field in a struct.

Bug: chromium:762167
Change-Id: I621d5c88283b1d066158559aade8811a9825c72e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2426743
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-23 20:25:35 +00:00
Joshua Peraza
36d4bb83b3 Remove base dependency from no_cfi_icall
crashpad_handler_trampoline needs to use NoCfiIcall, but does not link
libstdc++ in order to remain small. A dependency on base causes link
errors in ASAN builds:

https://ci.chromium.org/p/chromium/builders/ci/android-asan/7791?

This CL depends on
https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/2405651
in order to include "build/build_config.h".

Change-Id: Ie0344b7ead9c019cdda8a6e37ea8ec9cd5bf72b0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2405650
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-21 21:25:08 +00:00
Scott Graham
1c77abe909 fuchsia: Centralize disabling of Wconversion
Because of the multiple-worlds building of the Crashpad code in the
Fuchsia tree (with the Fuchsia BUILDCONFIG.gn in particular) there's no
good location to globally disable Wconversion for all of crashpad.

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

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

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

Bug: chromium:911896
Change-Id: Ibb0b8a4e4dc7fae1d24d18823f8dbb6da31f8239
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2332402
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-12 07:36:53 +00:00
Shai Barack
90344b24ed fuchsia: suppress -Wconversion warnings
Bug: fuchsia:56258
Bug: fuchsia:58162
Change-Id: I0b74e1786c169bef4e44ab54a19ffba79063474a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2405375
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-11 22:00:00 +00:00
Joshua Peraza
3e065b11d0 linux, mac: disable cfi-icall for cross-dso calls
CFI attempts to verify that the dynamic type of a function object
matches the static type of the function pointer used to call it.

https://clang.llvm.org/docs/ControlFlowIntegrity.html#indirect-function-call-checking

However, the analyzer does not have enough information to check
cross-dso calls. In these instances, CFI crashes upon calling the
function with an error like:

pthread_create_linux.cc:60:16: runtime error:
control flow integrity check for type
'int (unsigned long *, const pthread_attr_t *, void *(*)(void *), void *)'
failed during indirect function call
(/lib/x86_64-linux-gnu/libpthread.so.0+0x9200):
note: (unknown) defined here pthread_create_linux.cc:60:16:
note: check failed in crashpad_handler,
destination function located in /lib/x86_64-linux-gnu/libpthread.so.0

Change-Id: Ib29dabfe714f2ee9cc06a5d17e6899ff81a06df4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2339332
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-10 22:15:29 +00:00
Mark Mentovai
9a5a789123 mac: Fix MacOSVersionNumber for 10.12.0 < version < 10.13.4
In 5412beb63386, I asserted (via my code) that the kern.osproductversion
sysctl was introduced in 10.12.0, but this was utterly wrong. It’s not
available until 10.13.4. Compare 10.13.3
xnu-4570.41.2/bsd/kern/kern_sysctl.c to 10.13.4
xnu-4570.51.1/bsd/kern/kern_sysctl.c, look for osproductversion.

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

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

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

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

Bug: crashpad:347
Test: crashpad_util_test MacUtil.MacOSVersionNumber
Change-Id: Ic58d8ca8f04394d41c691dd2d946c59497ee71d5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2402248
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-09-10 13:53:29 +00:00
Mark Mentovai
fc97e5cbb2 mac: Work around broken {CTL_KERN, KERN_PROCARGS2} sysctl in 11.0db6
A new bug in macOS 11.0db6 20A5364e has broken the {CTL_KERN,
KERN_PROCARGS2} sysctl such that it will not work properly unless
provided with a buffer at least 17 bytes larger than originally
indicated. Work around the bug by providing a buffer a whole 32 bytes
larger.

Bug: crashpad:347, crashpad:355
Test: crashpad_util_test ProcessInfo.{Self,SelfTask,Forked}
Change-Id: I9324a63390875308979a10fefcd4c1c880651aee
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2399646
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-09-09 15:56:38 +00:00
Mark Mentovai
0bc3826129 mac-arm64: Allow target_cpu = "mac_universal" to create universal builds
When building for macOS and configured with target_cpu =
"mac_universal", bi-architecture x86_64/arm64 output will be produced.

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

Includes:

Update mini_chromium to e0008f2714a76c7f2a3854fa75774427a886d6b9

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

Bug: crashpad:345
Change-Id: I5ff2dce5ffae58186e33757aa94587f8eca20b99
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2387410
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 04:02:56 +00:00
Mark Mentovai
ca83774eea mac-arm64: Make MacModelAndBoard use target-type instead of board-id
Bug: crashpad:345
Test: crashpad_util_test MacUtil.MacModelAndBoard
Change-Id: I3eff29c2fc6ae646808cc9dbde8d0dbefd810962
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2386465
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 03:43:25 +00:00
Mark Mentovai
abfc89bb9b mac-arm64: Set expectations for tests that crash via __builtin_trap
__builtin_trap uses ud2 on x86_64, producing a SIGILL. On arm64, it uses
brk #1, producing a SIGTRAP. Test expectations must be adjusted
accordingly.

Bug: crashpad:345
Test: crashpad_snapshot_test MachOImageAnnotationsReader.CrashModuleInitialization, crashpad_util_test ExcServerVariants.*,ExceptionPorts.*
Change-Id: I22e75b7b48b8887031b1d95f1cea8a09733daf49
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2386464
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-09-04 03:41:05 +00:00
Mark Mentovai
e0d8a0aa01 mac-arm64: Cope with signal handling quirks
On x86_64, it’s impossible for a signal handler distinguish between
SIGBUS caused synchronously by a hardware fault and SIGBUS raised
asynchronously by software. This remains true on arm64, and is expanded
to include both SIGILL and SIGSEGV.

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

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

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

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

More information can be found at go/cros_is_linux_os_linux

BUG=chromium:1110266
TEST=manual build

Change-Id: Ie765da1ab6a0bf0286538ae1df3697abaa29aeaa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2391116
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-09-03 19:12:04 +00:00
Mark Mentovai
df3bc64246 mac: Be more positive
4ae896bad0af replaced OS_MACOSX with OS_APPLE and introduced OS_MAC,
disentangled from OS_IOS. This allows !defined(OS_IOS) to be written
more directly as defined(OS_MAC) in cases where OS_APPLE is assured.

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

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

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

This change was made mostly mechanically by:

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

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

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

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

Change-Id: I6bdc0b81a0294040e4dceb18576ab38c45a430e4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2345384
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2020-08-25 00:09:48 +00:00
Joshua Peraza
2f66eefb79 Update language to eliminate 'whitelist'
Change-Id: I6afe27313093c6867d0276274e6b17b195d9d263
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2339536
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-08-06 21:03:16 +00:00
Avi Drissman
4ae896bad0 Migrate to OS_MAC and OS_APPLE in Crashpad
This migrates:

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

Bug: chromium:1105907
Change-Id: I1b4abc19bbbe8df90e9c6e64cd29324b40b8ab71
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2321777
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-28 02:35:48 +00:00
Joshua Peraza
06a688ddc1 linux: setup a signal stack
Bug: crashpad:340
Change-Id: I035d988bc8e76dbf80c07f0c92b07dbefeba8bd1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2209768
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-15 19:00:09 +00:00
Mark Mentovai
fd001f792e build: Make crashpad_dependencies="external" work in the GN build
…for macOS, at least.

Change-Id: Iba45328d957de17198180d171677a45468c9adc2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2290842
Reviewed-by: Eric Astor <epastor@google.com>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-07-11 03:33:33 +00:00
Mark Mentovai
030c58c295 mac: Add missing #include "build/build_config.h" for ARCH_CPU_*
This #include was omitted from 0c3f50c8e14a.

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

This is mostly a lot of CPU context shuffling.

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

This is mostly a lot of CPU context shuffling.

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

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

Roll mini_chromium ae14a14ab..cd26c5101

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

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

The Windows and Fuchsia builds are broken, so…

TBR: epastor@google.com
Change-Id: I8aebbbc24db261f3c3377210bb1c477132964828
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2270920
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-27 04:56:14 +00:00
Eric Astor
f4b906c79c Avoid use of a Linux-only header in cross-platform code
Change-Id: I358ee1d7e09868e64df1f1dc6c0f49e40099ff16
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2259336
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-24 17:31:40 +00:00
IrinaShkviro
4145699874 win,linux: implement attachments support
Implemented the AddAttachment(), InitializeAttachments(), CleanDatabase() functions
on Windows.

Added attachment=FILE_NAME option to the handler, and
"attachments" argument for Windows and Linux to StartHandler function.
On crash it will create the corresponding attachments in the database
and copy content of the specified files to the database.

Bug: b/157144387

Change-Id: Ia238de39028e07112a7b971b5b7d5e71a5864f53
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2248099
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2020-06-24 16:19:27 +00:00
Eric Astor
7409adbff3 Make kMaxSendRecvMsgFDs constexpr-accessible in external contexts
Change-Id: I474186f30f38fb61e656315ebcbdc72d6b107d4e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2259333
Commit-Queue: Eric Astor <epastor@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-24 15:34:47 +00:00
Hans Wennborg
9520afb599 Add missing base/logging.h include
Bug: chromium:1031540
Change-Id: I7030ce615105ff96eefba2aee43361888517a846
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2257915
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
2020-06-22 20:12:12 +00:00
Hans Wennborg
161bfed35a Remove/replace unnecessary includes of logging.h
If the file just needs the CHECK/CHECK_OP/NOTREACHED
macros, use the appropriate header for that instead.
Or if logging.h is not needed at all, remove it.

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

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

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

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

Bug: chromium:1031540
Change-Id: I36f646d0a93854989dc602d0dc7139dd7a7b8621
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2250251
Commit-Queue: Hans Wennborg <hans@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-18 13:51:20 +00:00
Piotr Tworek
a8ff626764 Add a bunch of missing string.h includes.
There are a few files in the tree which use various functions defined
in string.h (memcpy, strlen, strnlen, memmove, etc), but never include
the necessary header file. After I've recently updated one of my systems
to a newer glibc version (2.30) this code failed to build. Adding the
missing includes fixes the problem.

The undeclared functions for each file are:
* simple_address_range_bag.h - memcpy
* http_multipart_builder.cc - strlen
* minidump_context_converter.cc - memcpy
* ptrace_client.cc - strlen
* http_transport_socket.cc - strncpy, strlen, memcpy
* process_memory.cc - memchr
* log_output_stream.cc - strlen

Change-Id: I3108c36b8a6927ac11f6839606cb495926fa9e4e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2207139
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-05-18 13:54:02 +00:00
Mark Mentovai
a45eea40fc Update gtest to e3f0319d89f4cbf32993de595d984183b1a9fc57
I’m most interested in picking up 1b3eb6ef3462, “Explicitly define copy
constructors used in googletest tests.”

This also reorganizes files and rewrites text to refer to this project
as Google Test and googletest (and Google Mock and googlemock), as it
prefers to be known. Some filenames are left at gtest_* following the
precedent set by gtest itself. For example, #include "gtest/gtest.h" is
still used, so #include "test/gtest_death.h" is retained too.
gtest_all_test OutputFileHelpersTest.GetCurrentExecutableName hard-codes
the expected executable name as gtest_all_test among other options that
do not include googletest_all_test, so test executables retain their
names as well.

fb19f57880f6 Add GTEST_BRIEF option
3549237957a1 Ensure that gtest/gmock pkgconfig requirements specify
             version
189299e957bb Merge branch 'master' into quiet-flag
5504ded3ab5c Fix a typo in .travis.yml
6ed4e7168f54 Replace the last instance of `throw()` with `noexcept`. NFC
879fd9b45299 Remove duplicate codes existed in get-nprocessors.sh
644f3a992c28 gtest-unittest-api_test - fix warning in clang build
0b6d567619fe Remove redundant .c_str()
be3ac45cf673 fix signed/unsigned comparison issue (on OpenBSD)
b51a49e0cb82 Merge pull request #2773 from Quuxplusone:replace-noexcept
c2032090f373 Merge pull request #2772 from Quuxplusone:travis
4fe5ac53337e Merge pull request #2756 from Conan-Kudo:fix-pkgconfig-reqs
373d72b6986f Googletest export
4c8e6a9fe1c8 Merge pull request #2810 from ptahmose:master
71d5df6c6b67 Merge pull request #2802 from e-i-n-s:fix_clang_warning
dcc92d0ab6c4 Merge pull request #2805 from pepsiman:patch-1
4f002f1e236c VariadicMatcher needs a non-defaulted move constructor for
             compile-time performance
9d580ea80592 Enable protobuf printing for open-source proto messages
766ac2e1a413 Remove all uses of GTEST_DISALLOW_{MOVE_,}ASSIGN_
11b3cec177b1 Fix a -Wdeprecated warning
01c0ff5e2373 Fix a -Wdeprecated warning
c7d8ec72cc4b Fix a -Wdeprecated warning
1b066f4edfd5 Add -Wdeprecated to the build configuration
4bab55dc54b4 Removed a typo in README.md
a67701056425 Googletest export
fb5d9b66c5b0 Googletest export
1b3eb6ef3462 Googletest export
b0e53e2d64db Merge pull request #2797 from Jyun-Neng:master
d7ca9af0049e Googletest export
955552518b4e Googletest export
ef25d27d4604 Merge pull request #2815 from Quuxplusone:simple
129329787429 Googletest export
b99b421d8d68 Merge pull request #2818 from inazarenko:master
472cd8fd8b1c Merge pull request #2818 from inazarenko:master
3cfb4117f7e5 Googletest export
0eea2e9fc634 Googletest export
a9f6c1ed1401 Googletest export
1a9c3e441407 Merge pull request #2830 from keshavgbpecdelhi:patch-1
e589a3371705 Merge pull request #2751 from calumr:quiet-flag

Change-Id: Id788a27aa884ef68a21bae6c178cd456f5f6f2b0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2186009
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-05-07 14:56:07 +00:00
Justin Cohen
95b4e62768 ios: CaptureContext arm64.
Change-Id: I2db8ead3103391af4d198f213524ea34ffef022b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2167211
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-05-03 19:21:45 +00:00
Mark Mentovai
2f217736a3 ios: Deal with ios_enable_relative_sdk_path in Chromium
Change-Id: Ibb03748d8881c4a71662a7d6ad5743107ccd748d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2174267
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-05-02 00:34:22 +00:00
Mark Mentovai
174a92d296 mac, ios: Add ExceptionPorts::SwapExceptionPorts
Change-Id: Ia4044c82440af1d05c24ee502d51eef5185cbeec
Test: crashpad_util_test ExceptionPorts.*_Swap*
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2170546
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-28 16:43:41 +00:00
Mark Mentovai
57e807da6d ios: Build (and test) SymbolicConstantsMach
Bug: crashpad:31
Test: crashpad_util_test SymbolicConstantsMach.*
Change-Id: Ia76a5fb2d5ca2afdd06d99dab9ab1b72cd5a6f0d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2169867
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-28 16:43:32 +00:00
Mark Mentovai
ecc41d0229 doc: Update Doxygen to 1.8.18 and fix Doxygen warnings
% doxygen -u doc/support/crashpad.doxy
[…warnings about removing obsolete TCL_SUBST, PERL_PATH, MSCGEN_PATH…]
Configuration file 'doc/support/crashpad.doxy' updated.
% doxygen -v
1.8.18

Change-Id: I771f654713042b0040873355051b9efaf46bffd1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2165817
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-27 16:45:20 +00:00
Mark Mentovai
a5a1c3b07f Add .style.yapf and reformat according to yapf, using “google” style
% yapf --in-place $(git ls-files **/*.py)
% yapf --version
yapf 0.30.0

Note that this is not using the “chromium” yapf style because Chromium
is moving to PEP-8.
https://groups.google.com/a/chromium.org/d/topic/chromium-dev/RcJgJdkNIdg
yapf 0.30.0 no longer recognizes “chromium” as a style option.
22ef70f3c4
Since this is a mass reformatting, it might as well move things all the
way into the future all at once.

This uses the “google” style, which is a superset of “pep8”.

Change-Id: Ifa37371079ea1859e4afe8e31d2eef2cfd7af384
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2165637
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2020-04-27 13:59:09 +00:00
Mark Mentovai
29b1688c11 Replace remaining uses of NULL with nullptr
I did a mass conversion in 5d74f120fc57 (October 2014) but these few
must have shown up after.

This excludes code in third_party.

Change-Id: I61cb0273804c0424904a516ed5ab735548b6b9cb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2166725
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-27 13:58:49 +00:00
Justin Cohen
be57546fea ios: Fix Chromium banned warning about NULL.
Change-Id: I29eefb067b171fb3d8ef9fa93c3bb146a206c9ce
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2166724
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-04-27 03:23:29 +00:00
Justin Cohen
17a515d33d [ios] Bring up first draft Mach exception server.
Add Mach exception server and fill out exceptions snapshot.

Note that:
 - The 'capture' portion of this CL will be moved out of the snapshot
   interface and into a separate in-process dump to disk location.
 - All of the pointer dereferences need to be wrapped in vm_read.
 - The read-fast-and-dump logic in exception_snapshot will end up in a
   different file completely, but until we pick a
   serialization/deserialization method, keep it as-is.

Bug: crashpad:31
Change-Id: I44203aa44036a341d6b4517fde7ab0cb9d7e94d7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2160122
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-04-25 23:38:48 +00:00
Scott Graham
069fddf184 fuchsia: Remove unused sysinfo dep
This was previously used, but is no longer required. Delete the one
remaining include at the build rules.

Change-Id: If5083a4fb8a5562d3e40149976bd27fcec0fd302
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2165635
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Francois Rousseau <frousseau@google.com>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2020-04-24 20:00:17 +00:00
Mark Mentovai
adfd94a357 ios: Use compat to provide items missing from the iOS SDK
This updates the way that the .defs files added in 1bfd7d06ed60 are
treated, by putting them in compat/ios, using compat as intended. The
.defs files in compat forward, via #include, to the ones in
third_party/xnu. Additionally, compat/mac is enabled for iOS, as
everything in compat/mac is sensible on iOS, and will have no effect
when rendered unnecessary by the iOS SDK.

This also changes util:mig_output to a static_library instead of a
source_set. I don’t think there was any reason for it to have been a
source_set to begin with. static_library is preferred for nearly
everything.

Bug: crashpad:31
Change-Id: I7c468d6d6785bf2bc825d45831ebb81e1c9ddfbc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2160310
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-22 16:09:05 +00:00
Mark Mentovai
64b8791f45 ios: Build util/mach/exc_server_variants.cc, support code, and tests
This makes UniversalMachExcServer available on iOS.
UniversalMachExcServer is the foundation for a Mach exc and mach_exc
server.

Some code in UniversalMachExcServer needs to be evaluated to ensure that
portions that run in the same process that has sustained the exception
are safe to do so at that time. For example,
SimplifiedExcServer<ExcTraits>::Interface instantiates and appends to a
std::vector<>, which is generally unsafe in this context. However, that
code responds to exc requests. The mach_exc equivalent,
SimplifiedMachExcServer<MachExcTraits>::Interface, does not use a vector
at all.

This also enables support code in the form of CompositeMachMessageServer
and UniversalExceptionRaise, all of the tests for
CompositeMachMessageServer, and most of the test for
exc_server_variants.cc. The multiprocess-based exc_server_variants tests
remain disabled on iOS.

Bug: crashpad:31
Change-Id: I838ed770a33ca29c37383c32245eb340fb3ad2fb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2159287
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-21 19:26:24 +00:00
Mark Mentovai
1bfd7d06ed ios: Run mig with the correct SDK and architecture
mig was being invoked without any -arch argument, causing it to assume
the build system’s native architecture, which would be x86_64. This is
not correct for iOS device builds, which use arm64. The -arch argument
must be plumbed to mig for correct behavior.

When building for iOS, mig was being invoked without any -isysroot
argument, causing it to use the root for the build system, which runs
macOS and not iOS. The macOS SDK doesn’t include the ARM definitions
needed for iOS device builds.

<mach/exc.defs> and <mach/mach_exc.defs> depend on a small number of
other .defs files to provide definitions of standard types. All .defs
files are absent from the iOS SDK. These .defs files are borrowed from
xnu and placed in third_party/xnu. An additional --include argument is
added to allow mig to locate these files.

Bug: crashpad:31
Change-Id: I27154310352939ebe2fb6329bbbfda701c369289
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2159291
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-21 19:24:44 +00:00
Mark Mentovai
3e748e9c4e ios: Provide a copy of mach_exc.defs and run mig on it
This updates (and corrects) 8dbbaff2e1a5, which added exc.defs, by
adding mach_exc.defs too.

The difference betwen the exc and mach_exc subsystems is that the |code|
parameter is int[] in exc and int64_t[] in mach_exc. Many exceptions
carry the exception address in code[1], and a 32-bit int results in the
exception address being truncated in exc. No information is lost in
mach_exc, where a 64-bit int64_t is used.

In 8dbbaff2e1a5, I misremembered the type of the |code| parameter as a
type derived from uintptr_t, such as vm_address_t, an integer as wide as
a pointer. I was wrong, and mach_exc is necessary. I also noted that
Apple normally forbids mach_-prefixed interfaces in favor of the
prefix-less ones for the reasons I mentioned, and that, all else being
equal, it was desirable to adhere to the spirit of that convention.
Because neither exc nor mach_exc are available in the SDK, it’s moot
from a technical perspective, as we need to provide our own stubs either
way.

Bug: crashpad:31
Change-Id: Ied1be470e653b2bead1a283cb8b9283d210c328d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2159286
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-21 19:23:24 +00:00
Mark Mentovai
4cb79941fc ios: Build four more Mach message and exception utilities
This enables the following code in util/mach on iOS:
 - exception_behaviors.{cc,h}
 - exception_ports.{cc,h}
 - mach_message.{cc,h}
 - mach_message_server.{cc,h}

Only the ExceptionBehaviors and MachMessage tests are built, because the
other two are tested by multiprocess tests that won’t run on iOS.

The AuditPIDFromMachMessageTrailer function from mach_message.h is
excluded on iOS because it relies on <bsm/libbsm.h>, which is broken on
iOS: it depends on <bsm/audit_record.h>, which is missing from the SDK.
Additionally, the BSM function that Crashpad uses, audit_token_to_au32,
is marked as unavailable on iOS. Crashpad uses it on macOS to
authenticate Mach messages sent by other processes, but this is moot on
iOS.

Bug: crashpad:31
Change-Id: I5ebc4b80543989b9cd0b85b82eb4b3ff98c44e6c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2155086
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-18 03:27:59 +00:00
Mark Mentovai
8dbbaff2e1 ios: Provide a copy of exc.defs and run mig on it to generate exc stubs
The iOS SDK doesn’t include a copy of <mach/exc.defs>. It only provides
<mach/exc.h>, which is just the user-side header. To obtain declarations
and implementations of the server-side stubs, a current copy of
<mach/exc.defs> is added to third_party, and the mig action in util is
updated to use it on iOS.

The three other mig subsystems that Crashpad uses are not brought to
iOS:
 - mach_exc is identical to exc except it always uses 64-bit quantities
   for addresses in place of exc’s use of quantiies sized for native
   pointers. Because all iOS work is limited to a single process, there
   is no need to consider cross-process operation with variable bitness,
   so mach_exc is unnecessary. We’re also only targeting 64-bit for iOS,
   so exc will always suffice. This follows the spirit of other
   mach_-prefixed routines on iOS, where Apple forbids mach_vm_read to
   user applications but permits vm_read.
 - notify is primarily used on macOS in the Crashpad handler process to
   receive a no-senders notification, which is used to trigger handler
   shutdown when it has no more clients. This is not believed to be
   useful to Crashpad on iOS, which is restricted to single-process
   operation.
 - child_port is a Crashpad-specific subsystem used to pass Mach rights
   between processes, but is similarly useless when restricted to
   single-process operation as on iOS.

Bug: crashpad:31
Change-Id: Id4cb3cdd529814438d378c20702c82c1e89dd2be
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2154530
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
2020-04-17 21:11:57 +00:00
Mark Mentovai
ba24acb86c ios: Split bootstrap out from mach_extensions
mach_extensions is sensible on iOS, but bootstrap is not available
outside of macOS. To allow mach_extensions to be used cleanly on iOS,
the bootstrap code is moved into its own macOS-specific file.

Bug: crashpad:31
Change-Id: I7bf9d5194253b563954a1e55fbf67a16f686e8ff
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2154529
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-17 20:54:47 +00:00
Mark Mentovai
122a400d7b ios: Enable (and test!) more of util and test
This builds some code in the util and test libraries on iOS that was
previously excluded. It also enables tests for this code, and other
tests that it was possible to enable either previously or as a result of
this change.

Previously, crashpad_util_test ran 178 tests from 46 test suites, and
crashpad_test_test ran 2 tests from 2 test suites. Now,
crashpad_util_test runs 284 tests from 62 test suites, and
crashpad_test_test runs 6 tests from 4 test suites.

The related .gn files also suffered through a slight cleanup.

Bug: crashpad:31
Change-Id: I84cdda5631f0ea4888ada902a8462776ac46fd2a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2154526
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-17 20:54:17 +00:00
Justin Cohen
ea4af71c2a Add another iOS library path sinkhole.
Add another sinkhole for _UIGestureEnvironmentUpdate.

Bug: crashpad:31
Change-Id: Ic4a424da034249295b6e45f8fe0860a4d4696b93
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2145017
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-04-16 15:25:57 +00:00
Mark Mentovai
e621aaa132 Make “gn check” pass
Change-Id: Ia7a215e1a2d0a3b1868b00c5d47b46ef8a675cdc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2144917
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-13 18:29:42 +00:00
Justin Cohen
b2fd7d5307 [ios] Bring up first half of UncaughtExceptionHandler.
When code raises an Objective-C exception, unwind the stack looking for
any exception handlers. If an exception handler is encountered, test to
see if it is a function known to be a catch-and-rethrow 'sinkhole'
exception handler. Various routines in UIKit and elsewhere do this, and
they obscure the exception stack, since the original throw location is
no longer present on the stack (just the re-throw) when Crashpad
captures the crash report. In the case of sinkholes, trigger an
immediate exception to capture the original stack.

The is an improvement over the alternative,
NSSetUncaughtExceptionHandler, which passes along the stack frames, but
not the stack memory contents and full exception context itself.

The details of what happens after a fatal exception is triggered are
unresolved in this CL.  For now, simply call std::terminate.

This code was inspired by chromium/src/chrome/browser/mac/
exception_processor.mm.

Bug: crashpad:31
Change-Id: Ieebc6476a0507c466c8219c10f790ec0a624e58c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2125254
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-04-08 20:57:21 +00:00
Joshua Peraza
c4cc4e6ac9 android: initialize signal dispositions
Bionic installs signal handlers which request crash
dumps from Android's debuggerd, but there are errors
in how signals which aren't automatically re-raised
are handled on Marshmallow (API 23).

Before requesting a dump, Bionic acquires a lock to
communicate with debuggerd and expecting imminent
death, never releases it.

While handling the dump request, debuggerd allows
the dying process to continue before
ptrace-detaching it. So, when Bionic manually
re-raises a signal, it is intercepted by debuggerd
and the dying process is allowed to live.

Bionic restores SIG_DFL for the signal it's just
handled, but if a different crash signal is later
recieved, Bionic attempts to reacquire the lock to
communicate with debuggerd and blocks forever.

Disable Bionic's signal handlers for these signals
on Marshmallow.

Bug: chromium:1050178
Change-Id: Ia1fc5a24161a95931684d092ba8fee2f0dfbbdbb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2134513
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-04-08 17:21:05 +00:00
Justin Cohen
af62d7fcf6 Correct use of -[NSString UTF8String].
Fixes the chromium presubmit error for UTF8String:
 The use of -[NSString UTF8String] is dangerous as it can return null
 even if |canBeConvertedToEncoding:NSUTF8StringEncoding| returns YES.
 Please use |SysNSStringToUTF8| instead.

Bug: crashpad:31
Change-Id: Iaf939012ea9d342f6a01af58119cef962319aefe
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2119613
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2020-03-26 04:19:33 +00:00
Justin Cohen
d9c1ca1216 [ios] Bring up first draft system snapshot and iOS data collector.
Gather most of the necessary information for the system snapshot.

Note that:
 - The 'capture' portion of this CL will be moved out of the snapshot
   interface and into a separate in-process dump to disk location.
 - All of the pointer dereferences need to be wrapped in vm_read.
 - The read-fast-and-dump logic in thread_snapshot may end up in a
   different file completely, but until we pick a
   serialization/deserialization method, keep it as-is.

Bug: crashpad:31
Change-Id: Iac82491fdb4a823163f02149f52a1e18e26fa9de
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2090173
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-03-25 20:31:06 +00:00
Joshua Peraza
b75c578373 linux: disable arguments test on old kernels
Bug: chromium:1050178
Change-Id: Ideafa5971cbaf76fa6865f671158958e7abb3a8c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2117366
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-03-24 21:05:17 +00:00
Nico Weber
2965013518 Prepare crashpad mig stuff for -Wunreachable-code in chromium_code.
Bug: chromium:346399
Change-Id: I5d93a2f6781dd4dd3483009d9c470050d490be3c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2116252
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
2020-03-23 20:18:51 +00:00
John Bauman
9a31d3f8e9 Print thread state after failure to suspend
This may help us debug some issues where the thread is failing to
suspend.

Bug: b/151318587
Change-Id: I0d2d539f769ebb1cdd71606e1d23d8fa66673879
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2103411
Commit-Queue: John Bauman <jbauman@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2020-03-13 22:48:26 +00:00
Joshua Peraza
7500e2ef45 linux: add fallback-modes for memfd_create
Bug: chromium:1051354
Change-Id: I5dbbb3b264c09060429db199aa9f046c2f317c48
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2080651
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-03-03 18:09:45 +00:00
Justin Cohen
3c573b54ae [ios] Fix iOS device build.
Change-Id: Ib0f5af9680b4b626df2da006789eb846cd38579d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2081269
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2020-03-03 02:11:41 +00:00
Leonard Chan
8bad6f140e [UBSan] Temporarily disable UBSan for gtest and file
These should be the remaining instances of UB errors we see.

Bug: fuchsia:46805
Change-Id: Id8285386fd6cb52518f6076ddb79ac60025f9f87
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2067754
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2020-02-24 17:26:35 +00:00
Justin Cohen
9ed8290547 Bring up skeleton crashpad_client_ios.
First steps at bringing up the crashpad_client on iOS.  Also updates
the XCUITest to trigger various crashes, with some swizzling
necessary to allow crashes.

Change-Id: I87dd36bed1c052b509d14bfa29679ed81e58a377
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2039470
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
2020-02-18 20:03:41 +00:00
Joshua Peraza
faed21a286 linux: Log register sizes on mismatch
Bug:1051354
Change-Id: Ia7731a87420e61756b61d109f9c69970ec27c6cb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2062776
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-02-18 19:38:58 +00:00
Joshua Peraza
07812f5bd6 android: fix the gyp build
Change-Id: Ic54fd61258f4ea5b3aaa83a252faa0053ca1f552
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2062773
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-02-18 19:24:21 +00:00
Nico Weber
7ed4d5c454 arm: Properly mark _ZN8crashpad14CaptureContextEP10ucontext_t as %function
lld wants to remove bl/blx substitution for non-function symbols
(https://reviews.llvm.org/D73542). GNU ld apparently already doesn't
do it.

Since _ZN8crashpad14CaptureContextEP10ucontext_t wasn't marked as a function,
chromium's thumb code would then branch without mode transition into
crashpads non-thumb assembly (in arm32).

So mark the symbol as function, so that things work even if that patch
relands. This should also make things work with GNU ld, though I haven't
verified that it was broken before and works now.

I also did this for aarch64 since it seems like The Right Thing To Do
(assuming the assembler accepts it, which I also haven't checked --
the CQ will hopefully check that).

Bug: chromium:1049649
Change-Id: I3452c16f0d52a2dc0397fd3d60d06b5c39a4b524
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2044144
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
2020-02-07 23:42:19 +00:00
Tao Bai
915862984c [log minidump] add option to log minidump in handler_main
- Add option to log minidump in handler_main, also add option to
  disable to dump minidump and generate report.
- Implement log minidump in CrashReportExceptionHandler.

Bug: crashpad:308
Change-Id: I8d2f7e118912011a8416f1ec36c9ee9d561d06e6
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1995825
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2020-01-30 18:06:58 +00:00
Nico Weber
2fd16e3392 Reformat all gn files
Port of chromium-side
https://chromium-review.googlesource.com/c/chromium/src/+/1997899

Bug: chromium:1041419
Change-Id: Ic7afefa0dea024da37fe4bb0f965840a160e2166
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2015428
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-01-23 13:59:00 +00:00
Tao Bai
b411976ca5 [log minidump] add tool to encode/decode minidump log.
- This tool could compress/encode or decode/decompress the minidump
  log file, will be used by script to symbolize the crash.
- Added FileOutputStream and FileEncoder.

Bug: crashpad:308
Change-Id: I15c3e4908882a09983ec81a90e38249967c29fc4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1968059
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-12-18 22:16:48 +00:00
Joshua Peraza
d3d0c8d3ca android: don't expect code addresses to be readable
Change-Id: I252a93db5f4166216664ae8f67e331fc7eed8852
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1967548
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-12-13 18:58:42 +00:00
Tao Bai
fa28ef896c [log minidump] LogOutputStream implementation
Emit the received data to Android logcat in Android, and noop for
other platforms.

Bug: crashpad:308
Change-Id: I6e46e2fa8bd61f93f614ad0bfb6441a79139b04b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1958711
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-12-12 23:04:38 +00:00
James Forshaw
c6153f0b6e [Windows] Add AppContainer SID to Named Pipe DACL.
This CL modifies the creation of the Named Pipe Security Descriptor to
allow access from AppContainer processes. The DACL only allows access for
the current user and SYSTEM which matches up with the auto-assigned DACL
used previously (the read-only logon SID ACE has been removed). As this
new code uses APIs from ADVAPI32 a check is made to ensure it's not being
called while the loader lock is held to avoid hitting previous similar
issues.

Bug: crashpad: 318
Change-Id: I3f9cf5c788dbadacad21c8a2d57a0188f690ac32
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1955982
Commit-Queue: James Forshaw <forshaw@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-12-10 17:16:24 +00:00
Tao Bai
3e4d6a9b7f [log minidump] Base94OutputStream implementation
Add Base94 encoding/decoding implementation and tests.

Bug: crashpad:308
Change-Id: If3f25efcb277eacd5d8cbe1d66f22919872c7d64
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1796682
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-12-06 19:27:33 +00:00
Mark Mentovai
31470459b6 Fix line endings on files introduced in 359fc4a1336d
"\r\n" was used instead of "\n" on four new files.

No other "\r" appears in any text file, repository-wide.

Bug: crashpad:316
Change-Id: I94f5d20cd2498e76efdee6062382669362e6e53d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1954713
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-12-06 04:24:30 +00:00
Joshua Peraza
bcab7ad54c linux: handle large mapped files
Chrome on Android normally builds the handler without large file
support because support for large files varies by API level and NDK
version.

https://cs.chromium.org/chromium/src/build/config/compiler/BUILD.gn?rcl=6b5017edcd8544acbdb157086a1645ce36c03057&l=360

https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md#32_bit-and

The handler still needs to able to handle large files mapped by other
code modules.

Bug: crashpad:312
Change-Id: I1022b706797f41445650f82c425a92e6e2308618
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1954426
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-12-05 21:33:20 +00:00
James Forshaw
359fc4a133 [Windows] Add checks for DLL loader lock.
This CL adds code to check if the current thread holds the DLL loader
lock. This code can be used to enforce the requirement that certain
parts of crashpad, such as process creation are not done during calls
to DllMain which can lead to deadlocks and crashes. Only one check is
current enforced, in client process creation, and only in debug builds.

Bug: crashpad: 316
Change-Id: I5757a264bbf28ce2ab88a0cd7ac9481e46428c17
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1945993
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: James Forshaw <forshaw@chromium.org>
2019-12-03 21:42:32 +00:00
Joshua Peraza
74490f00a4 linux: roll lss and use sys_sigtimedwait/sys_sigprocmask
Bug: crashpad:265
Change-Id: I4b8f566e2a211cca96eef8a2c1098408a38bcf23
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1914840
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-11-13 22:10:54 +00:00
Joshua Peraza
2291bfa32e android, gyp: fix the build
Change-Id: If852448b5719310b73774cac635ef9c52a3efc22
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1914349
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-11-13 21:16:24 +00:00
Joshua Peraza
93f8aa8df9 posix: fix parameter name in signals test
Change-Id: I6e998571171c9a725d88a9529c73d01c62ee984f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1905146
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-11-08 04:02:38 +00:00
Joshua Peraza
6dadd492b8 linux: fix proc stat reader flakiness
ProcStatReader.Threads is flaky because it relies on an internal,
imprecise measurement of boot time. The flaky test asserts that a
thread started after the main thread should have a start time >= the
main thread. The start time is returned in a timeval, with microsecond
precision, but the measurement of boot time requires two system calls
and the time between those system calls can be approximately a
microsecond. An unlucky event such as a change in system time could
make this imprecision arbitrarily bad.

This patch lets the caller of ProcStatReader.StartTime() inject the
boot time, allowing ProcStatReader to guarantee that threads have
correctly ordered time, given the same input boot time.

Bug: 1016765
Change-Id: I6e4a944a1d58c3916090bab6a4b99573e71a89fc
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1891588
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-11-07 16:54:17 +00:00
Francois Rousseau
27322abb7e [net] specify parameter name in parameterized test suite
* this renders as "HTTPTransport/HTTPTransport.ValidFormData_Gzip/http"
  instead of the default "HTTPTransport/HTTPTransport.ValidFormData_Gzip/0"
* switch the parameter type from a base::FilePath::StringType to a string

Change-Id: I19743966406f92176c566827d74a79aef5a87bb5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1900324
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2019-11-06 01:35:18 +00:00
Joshua Peraza
1b60c8172c commit test ssl certificate to testdata
Chromium requires build artifacts to be generated deterministically so
commit a long-lived (10 years) test certificate to the repository.

Change-Id: I7a6e2441f506196ca58fbbf757648fa0ac70bc9a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1872188
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2019-11-05 17:47:01 +00:00
Joshua Peraza
661a07a41b linux: add deps for boringssl in chromium
Change-Id: Icc0acddd7218c85950874555405c8f8b5c3149dd
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1869251
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-10-18 15:37:06 +00:00
Joshua Peraza
47a342133d linux: use boringssl in chromium
Or else the uploader will check fail when uploading to https://...

Change-Id: I88a765215cc7bff5809b8effd92f4e39bebd1e5b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1860940
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-10-15 15:58:26 +00:00
Joshua Peraza
7289acb78a linux: don't assume vdso exists
AT_SYSINFO_EHDR may be defined even if no vdso is used. e.g. 32-bit ARM
processes have a vdso on 64-bit ARM cpus, but not on 32-bit cpus.

Change-Id: I4d9ce029bb47efc33ea16cb4c5c2055c1b9330c9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1860935
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-10-15 15:58:06 +00:00
Mark Mentovai
c009b85449 Use GTEST_SKIP() instead of custom DISABLED_TEST()
Since gtest 00938b2b228f, 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.

This was done previously in 79f4a3970a64, but was reverted in
bba9d0819c12 because Chromium’s test launcher did not support
GTEST_SKIP() at the time. The deficiency is on file as
https://crbug.com/912138.

While that bug was never specifically marked as “fixed” and I haven’t
found what changed in Chromium, I do now see some use of GTEST_SKIP() in
Chromium. I also prototyped this change in Chromium at
https://chromium-review.googlesource.com/c/1854691/ and found that
GTEST_SKIP() does indeed now appear to work.

Change-Id: I13fef8fe8bfd9854a40dfa5910a3282d1a85bc45
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1855380
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-10-11 16:45:34 +00:00
Joshua Peraza
eff0680c13 linux: silence logs on client disconnect
When all Crashpad clients have closed their crash handling sockets,
the handler's recvmsg() returns 0 and doesn't include any credentials.
Silence error logs for this normally occurring case.

Change-Id: I56acf3b38c8e95a9bbaa9bff04e0a6859a194e66
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1816286
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-09-20 18:45:57 +00:00
Alex Pankhurst
2bfd3c4edc [POSIX] stop logging on ENOENT
This change stops IsRegularFile and IsDirectory from logging
an error in the instance that a file or directory cannot be found.

Change-Id: I9f3c409933245708db775f566a27f5e49b2c71f3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1795924
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2019-09-13 16:16:18 +00:00
Joshua Peraza
e97cf7b29c update gyp_crashpad_android.py
This patch updates gyp_crashpad_android.py to function with NDK r20,
removes the requirement to generate a standalone toolchain, and updates
documentation on building for Android.

Also some gyp build fixes.

Change-Id: Ide338417ab2a21eca7a4bf42c1fb834e5639c186
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1798746
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-09-11 19:05:30 +00:00
Francois Rousseau
abeccef1ef [fuchsia] fix crashpad_use_boringssl_for_http_transport_socket path
* https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1745355/17/util/BUILD.gn#184 defines "defines" earlier in the target
* this only affects Fuchsia in the Fuchsia tree, not the Crashpad tree

TESTED=`fx build` in Fuchsia tree

Change-Id: I5ac454828f958d6de4e4c6788d7c9a31408dc732
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1796964
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2019-09-10 22:12:44 +00:00
Joshua Peraza
fc44a3747c linux: Allow configuring unhandled signals
Change-Id: I621555f892a3064c5cba09120309bc900da237f9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1793563
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-09-10 17:57:21 +00:00
Tao Bai
9a62344612 [Log minidump] OutputStream interface and zlib implementation
This is the 1st patch for logging minidump in Android. it adds
OutputStream interface and zlib implementation for output pipline.

Bug: crashpad:308
Change-Id: I4738b8f223886049e6e259b9b25c00e5120156e5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1745355
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-09-06 22:07:32 +00:00
Joshua Peraza
e1e55e2246 linux: initialize crash_loop_before_time member
Change-Id: I8910d0700056232afb82afc4ef1463212053f7e2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1782737
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-09-03 19:44:53 +00:00
Joshua Peraza
cd92fba233 linux: Move Cros crash handling to CrosCrashReportExceptionHandler
Change-Id: I80686ddc35b03fa213481e35dc494a40fbdd551a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1775222
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-08-30 19:49:26 +00:00
Tim Zheng
726ab2a655 Integrate Crashpad with Chrome OS
This CL adds modification to Crashpad to integrate Crashpad reporting
for Chrome on Chrome OS.

Design doc: go/cros-crashpad
BUG=chromium:944123

Change-Id: I22e2f2a93f32c2dc149c9c011fa8134cf6d5b74f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1707369
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-08-19 23:28:00 +00:00
Vlad Tsyrklevich
bde5196af5 Add ProcessMemorySanitized
The ProcessMemorySanitized implementation only allows reads to a given
process if it falls within a given whitelist of memory ranges. This
ensures that 'sanitized' snapshots only allow reading memory that was
explicitly allowed.

Bug: crashpad:263, chromium:973167
Change-Id: I72712d7ea3cabfd49cc91ffbe563cb349e6fcfdb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1752593
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-08-15 00:02:53 +00:00
Scott Graham
1b2f448720 Fuchsia: de-port generate_dump
generate_dump is not being used on Fuchsia (because only the system-reporter
version of Fuchsia Crashpad is actively used).

GetProcessFromKoid() is becoming increasingly difficult to implement, so simply
de-port generate_dump until we actually need it again in the future (if ever).

Removes GetRootJob().

Change-Id: Ib5e5d8e79177506da4b2e0e0382f3fdd2502840b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1726695
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Francois Rousseau <frousseau@google.com>
2019-07-31 15:43:46 +00:00
Istvan Romai
63782c8333 Added Windows on ARM support to SystemSnapshot::CPUVendor
Bug: crashpad:297
Change-Id: I1430f86986efdd7bc3c5494ce1838653c64524d6
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1647167
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-07-24 14:01:42 +00:00
Adam Kallai
79b59b0a8f Add support for capture CPU context on Windows on ARM64
Most Crashpad builds use Microsoft's armasm64.exe macro assembler
for .asm source files. When building in Chromium, clang-cl is used
as the assembler instead. Since the two assemblers recognize different
assembly dialects, the same .asm file can't be used for each.
As a workaround, use a prebuilt .obj file when the Microsoft-dialect
assembler isn't available.

The obj file is generated from the capture_context_win_arm64.asm
by armasm64 macro assembler. If this asm file is modified,
the obj file needs to be updated.

Change-Id: Id5a4a949997a27b04815aeb79b2540d30a52d34c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1632749
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-07-17 18:08:42 +00:00
David Pursell
137506bf1e [fuchsia] transition off deprecated exception APIs
Removes the remaining references to the old port-based exception APIs in
favor of the new channel-based APIs.

Bug: fuchsia:ZX-4031
Test: runtests on emulator and device
Change-Id: Ieac5b66c2f676966d1018d771cab6c8635f12a8f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1700321
Reviewed-by: Francois Rousseau <frousseau@google.com>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2019-07-12 19:32:53 +00:00
Vlad Tsyrklevich
1644b7724d Add missing build/build_config.h include
Change-Id: I1fa215d0d7c3925c27cf45702634269f4f6f2322
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1684438
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2019-07-01 22:43:26 +00:00
Vlad Tsyrklevich
b19842d25c Fix MSan failures
Bug: 932205
Change-Id: Ic31986d270634e42bf8c2620f37c434a4cb79b33
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1474271
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2019-06-28 23:00:24 +00:00
Joshua Peraza
d98690a182 android: enable upload
This patch also updates WorkerThread to execute DoWork() when
DoWorkNow() has been called, which is relevant when DoWorkNow() and
Stop() have both been called. This occurs regularly on Android where
the handler's current normal mode is to dump a single process and exit.
This change ensures the upload thread has a chance to upload the report
before the handler exits.

This change should not affect upload on Chrome/WebView/Chromecast which
don't pass Crashpad a --url option and are still responsible for their
own uploads.

Change-Id: Ie5553eafc13714f0438b4b133a92516f7abec153
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1643710
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-06-18 22:07:14 +00:00
Erik Chen
e0e83ad18a Use explicit paths when using hermetic toolchain.
Previously, both the invocation to mig and mig's internal code would use xcrun
to locate binaries. When we're using the hermetic toolchain, we want to
explicitly specify the binaries to use and we want to avoid calls to xcrun.

Bug: chromium:971452
Change-Id: I8527368e0846bc72789e6454fcd626b028d297ff
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1650147
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-06-07 19:23:49 +00:00
Adam Kallai
949a022939 win: Fix 64-bit detection in ProcessInfo
The ProcessInfo initialization fails on ARM on Windows with
'ReadProcessData failed'.

The 64-bit detection logic only checks whether it's on x64 and ignores
ARM64. On ARM64, the ReadProcessData template should be instantiated
with internal::Traits64 as it is on x64.

Test: Run crashpad_tests on ARM, 'ReadProcessData failed' is gone
Change-Id: I0f47d8601a39aaa1b8ba07d34d1f41b7739233e7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1615024
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-05-16 22:22:37 +00:00
Joshua Peraza
e23286dc37 linux: extend handler protocol with credential messages
This message type allows the browser to determine the handler's process
ID to be used with `prctl(PR_SET_PTRACER, ...)`.

Bug: crashpad:284
Change-Id: I2664f3e8aee269b159de9074e389397346c808f0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1577704
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-05-02 20:58:38 +00:00
Joshua Peraza
a11243e8f1 linux: add wrappers for send/recvmsg
sendmsg() and recvmsg() are complicated to use. Refactor their usage
into functions with a simpler, tested interface and use those instead.
This also adds CreateCredentialSocketpair() to create a pair of
connected sockets with SO_PASSCRED set. This option should be set
before the possibility of any calls to sendmsg() with the socket pair
to avoid race conditions in properly setting credentials.

Also update the handler to use Strategy::kNoPtrace (which causes the
crash dump to fail without breaking the socket connection) if the
credentials were invalid, which can happen if SO_PASSCRED was set after
the call to sendmsg() or if the sending process does not exist in this
namespace.

Change-Id: Id09f87125540255687a3c35d5bed7fa01ec07cff
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1584639
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-05-02 20:56:08 +00:00
Joshua Peraza
59cdfbb031 linux: support multi client sockets in ExceptionHandlerServer
Multi client socket connections allow multiple clients to request crash
dumps from a handler process using a single, shared socket connection.

This connection mode does not support using a broker process which
requires a dedicated socket connection to ensure handler messages
aren't intercepted by the wrong clients.

The handler uses SIGCONT to indicate to the crasher when a crash dump
is complete (or has failed) and may continue.

Bug: crashpad:284
Change-Id: I2031029cd254f17497cbf7e7d8740c289581e8aa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1559306
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-05-02 20:54:41 +00:00
Eric Astor
48675b4bd3 Remove pid_t in platform-independent code.
Change-Id: Ia58e07bf85a09cd7e63784220800431ad1366584
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1565273
Commit-Queue: Eric Astor <epastor@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-24 16:02:00 +00:00
Joshua Peraza
c96226c6ba linux: move handler protocol types into a class
This patch adds the class ExceptionHandlerProtocol to contain all the
relevant types, but should not make any functional changes.

Change-Id: I65ada239a6bf3195899fdd96f005c042cdd59749
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1575796
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-23 17:49:16 +00:00
Casey Dahlin
5f77cf41b6 Add CodeViewRecordBuildId
Until now we've been stuffing ELF debug symbol link information into a
CodeViewPDB70. This has reached the limits of its usefulness. We now add
a CodeViewRecord that can contain a proper ELF build ID.

Change-Id: Ice52cb2a958a1b9031943f280d9054da02d2f17d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1574107
Commit-Queue: Casey Dahlin <sadmac@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-22 23:16:22 +00:00
Joshua Peraza
c31a86a340 linux: Identify requesting threads
When a crashing process is in a different PID namespace than the
handler, the crasher doesn't have a way of knowing its own thread ID in
the handler's namespace and the kernel lacks mechanisms to perform this
translation before Linux 4.1 (where the information is present in
/proc/<pid>/status:NSPid).

This patch gives the handler a way of identifying the requesting thread
by sending a stack address along with the crash dump request, which
the handler can search for in each of the process' threads.

This information is useful both for attaching exception information
to the right thread and to allow the handler to send signals to the
correct thread when using a shared socket connection.

Bug: crashpad:284, crashpad:286
Change-Id: I4fa366c8fb17f932b056265cf71a4af160ba342f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1558828
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-16 18:29:20 +00:00
Eric Astor
e50676dcf2 Switch all string-number conversion to use fundamental types, and add long to the list.
Change-Id: I9244df09415f9d46262e2b8d04b64d7c4f786436
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1565287
Commit-Queue: Eric Astor <epastor@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-12 18:26:02 +00:00
Egor Pasko
ad49fcfad6 directory_reader_posix: more verbosity in PLOG
Bug: chromium:949321
Change-Id: I0c73d730ede912a7be0b22ea3ab384a8fda2e528
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1564512
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Egor Pasko <pasko@chromium.org>
2019-04-11 17:17:37 +00:00
Francois Rousseau
0730f0c60c [fuchsia] rename gn group to fuchsia
now that we import fuchsia-sysinfo and fdio, this isn't really just zx anymore

Change-Id: Ic42359ce3d230e214ebdbbefb880ccb021434a0f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1555533
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2019-04-05 23:33:12 +00:00
Joshua Peraza
7d5d5ff25f Avoid triggering buffer overflow detectors
Writing directly into buf.tmp causes the nul-terminator to overflow
into buf.crlf, which upsets some overflow detectors.

Bug: crashpad:289
Change-Id: I241f1ae239ed8360ac5dfd245cb70e919ae73cd1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1545014
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-03-29 15:34:02 +00:00
Francois Rousseau
3cc7ceaac5 [fuchsia] do not try to suspend crashed thread
* a thread blocked in an exception is technically not suspended on Fuchsia
* this will take care of the spurious error message "thread failed to suspend: ZX_ERR_TIMED_OUT (-21)" introduced in https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1536268

Bug: fuchsia/ZX-3772
Tested: `fx run-test crashpad_test` on Fuchsia; verified with `fx shell crasher` no error message
Change-Id: I5306732ef7c5a4f2c0fe84bc072506d57a43931e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1538558
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2019-03-25 20:45:09 +00:00
Adam Barth
aa160f6581 [fuchsia] Update header include
Previously, we included lib/fdio/util.h, but that header is being
removed. The declarations we need are in lib/fdio/fdio.h now.

Change-Id: I094b328766f1c67571044f85717b788eded1d142
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1508635
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Adam Barth <abarth@chromium.org>
2019-03-07 18:21:15 +00:00
Mark Mentovai
708367f5ba POSIX: ScopedMmap length refinement
9d26012e9c73 relaxed the requirement on ScopedMmap such that the length
of the region supervised no longer needed to be provided as a round
number of pages. This was accomplished by internally rounding up the
provided length to a page length. Unfortunately, this made

ScopedMmap::len() return something other than the passed-in length,
which is undesirable. This change makes ScopedMmap store the passed-in
length internally, making it available unmodified via the accessor, and
rounding it up to page length at internal points of use.

Change-Id: I827925af68e38f33bfa3cee535db0f098884fc6b
Reviewed-on: https://chromium-review.googlesource.com/c/1492774
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-02-28 01:51:41 +00:00
Mark Mentovai
2271f00fe0 Add missing BUILD.gn for third_party/apple_cf
apple_cf is just a header, but we’ve got a BUILD.gn for
third_party/cpp-httplib, which is also just a header.

Change-Id: Ib42c25657b5964678d14682a0a802ebef0e4cb2f
Reviewed-on: https://chromium-review.googlesource.com/c/1489182
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-02-26 16:39:24 +00:00
Mark Mentovai
9d26012e9c POSIX: don’t be overly restrictive about mmap() region length
ScopedMmap was asserting that the length of a mapped region must be an
exact number of pages, but this is not required or useful.

Change-Id: I6141712a1980a217565e31ddcd4c23cf6a32503c
Reviewed-on: https://chromium-review.googlesource.com/c/1480440
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-02-25 17:48:47 +00:00
Vlad Tsyrklevich
25ba1d6895 Explicitly check mach_vm_read() size out parameter
Explicitly check that mach_vm_read() successfully read the entire
requested region. This is a speculative fix for an infrequent crash that
occurs in the wild where only part of the region read by ReadMapped()
was actually mapped into memory.

Bug: chromium:918626
Change-Id: I4f4b3902d11480dc4a003608cfb1d371ec89425b
Reviewed-on: https://chromium-review.googlesource.com/c/1455170
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-02-20 21:45:51 +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
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
Victor Costan
0dde0ef81c Add missing using statement in notify_server_test.cc.
The test currently compile because of ADL (argument-dependent lookup). It
does not compile with a more recent googletest version. See associated
bug for linked to failed builds and compiler error messages.

Bug: crashpad:274
Change-Id: I7f2dd736453deb2a1af7bcacefc421961e1eb95e
Reviewed-on: https://chromium-review.googlesource.com/c/1422786
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2019-01-19 05:20:21 +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
Scott Graham
922b5750c1 fuchsia: Update for zx_task_suspend() supporting processes
zx_task_suspend() now supports suspending processes. This is somewhat
more reliable than suspending the constituent threads because after the
call returns and the token is being held, any subsequently started
threads will start in the the suspended state.

However, because the suspend is asynchronous the threads of the process
still need to be iterated to wait for them to assert ZX_THREAD_SUSPENDED
(and that can and does still fail to happen for a number of reasons). So
while improved, this class is still only best-effort.

Additionally, as the version of ScopedTaskSuspend that took a thread
wasn't being used, remove that.

Bug: crashpad:269
Change-Id: Ifb3f8e0d780a5e22af33613f92a61d25459f5139
Reviewed-on: https://chromium-review.googlesource.com/c/1377201
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2019-01-14 22:32:15 +00:00
Mark Mentovai
eb3f371879 mac: Update comment describing using Mach receive rights with kqueue()
The prohibition on using Mach receive rights with kqueue() was lifted in
10.12. Add the source code reference that should have been here all
along, and explain how xnu has changed. When the minimum runtime target
is 10.12 or later, the port set in this code will be unnecessary, and it
will be possible to remove it.

Change-Id: I8fdf91a124efb081e4748ccf60680b12a38c4d18
Reviewed-on: https://chromium-review.googlesource.com/c/1406894
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-01-11 19:08:46 +00:00
Vlad Tsyrklevich
732768cc9d Upstream change from chromium
This was part of a change to delete base::ThreadLocalStorage::StaticSlot.

Bug: crashpad:271
Change-Id: I0df76318aef05cbaecab660253cb388e3929f693
Reviewed-on: https://chromium-review.googlesource.com/c/1405788
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2019-01-10 23:15:29 +00:00
Joshua Peraza
ec676b3f67 linux: Use bit_cast to convert types
Change-Id: Ie7a5be80169850bbfa188b1f141f97d79683f9a5
Reviewed-on: https://chromium-review.googlesource.com/c/1401103
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-01-08 17:20:23 +00:00
Joshua Peraza
fb667c9892 linux: Handle negative offsets in MemoryMap
offsets in the MemoryMap are expressed as two's complement while
Crashpad's and mini_chromium's string conversion functions expect
negative numbers to be expressed with a '-' character.

Convert the string as unsigned and then re-interpret to signed when
necessary.

Bug: 914246
Change-Id: I76aaf092ea7ad98806be7a3f380dab4ca0425ed6
Reviewed-on: https://chromium-review.googlesource.com/c/1399372
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-01-08 05:49:46 +00:00
Reid Kleckner
b3eeffaa18 Use << instead of , to log "NtQueryInformationProcess"
Fixes a -Wunused-value warning found by the latest version of clang.

R=mark@chromium.org

Bug: 917419
Change-Id: I6178c1534adc7e25e5b75f6a6ab90497a86de23f
Reviewed-on: https://chromium-review.googlesource.com/c/1395945
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Reid Kleckner <rnk@chromium.org>
2019-01-04 23:19:17 +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
Eric Astor
3678bff13f Separates generating & fixing Mach interfaces with MIG.
Adds new scripts: mig_gen.py for using MIG to generate a Mach interface, mig_fix.py for fixing the resulting interface. mig.py now wraps both into the same user interface.

mig_fix.py also has the option to write its fixed output to new files, rather than overwriting the existing output. This should increase compatibility with certain build configurations.

Change-Id: I743ea1bab3f63c5b92f361948b544d498ed01cbc
Reviewed-on: https://chromium-review.googlesource.com/c/1389095
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-01-03 20:42:16 +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
Vlad Tsyrklevich
8f5d83b9e3 Change ProcessMemoryRange to use VMSize
Follow up to https://crrev.com/c/1387756 replace size_t with VMSize.

Bug: crashpad:270
Change-Id: I22ac9e3503ef3e9707b2ad0758ae133c5a746f27
Reviewed-on: https://chromium-review.googlesource.com/c/1389235
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2019-01-03 19:00:23 +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
60ff012872 Change ProcessMemory to accept VMSizes
As Mark noted in [1] ProcessMemory should accept VMSize instead of
size_t, the two types can differ on platforms where a cross-bitness
handler could cause a 32-bit handler to inspect a 64-bit process. By
centralizing the checks in ProcessMemory, we can leave the individual
platform-specific implementations (in ProcessMemory*::ReadUpTo) to
accept size_ts.

[1] crrev.com/c/1388017/2/snapshot/crashpad_types/crashpad_info_reader.cc#70

Bug: crashpad:270
Change-Id: I3aab483221de36f3b1478cb9503101b142dae681
Reviewed-on: https://chromium-review.googlesource.com/c/1387756
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-21 21:41:54 +00:00
Vlad Tsyrklevich
abfad376ab Add missing build/build_config.h includes
Didn't notice these until I hit presubmit in chromium.

Bug: crashpad:263
Change-Id: I7d86c508928c95a65b7972a19fbdf3bd19c9b29b
Reviewed-on: https://chromium-review.googlesource.com/c/1387885
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-20 23:03:08 +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
3f7d4d7d09 Break out redundant tests into a routine
Bug: crashpad:263
Change-Id: Ib6f05f5e7b91a434e54e0a8d6cd55078b2bf84f5
Reviewed-on: https://chromium-review.googlesource.com/c/1387269
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-12-20 20:49:18 +00:00
Vlad Tsyrklevich
4e3be595f3 Delete redundant TaskMemory tests
Delete TaskMemory tests made redundant by equivalent
ProcessMemoryTests. Some TaskMemory tests are still not redundant
because they test TaskMemory::ReadMapped() or they exercise platform-
specific behavior like TaskMemory::Read() not being able to read a
VM_PROT_NONE page.

Bug: crashpad:263
Change-Id: I72a56b4f3564444b02943f11a0069749bf1b074b
Reviewed-on: https://chromium-review.googlesource.com/c/1387270
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-20 20:30:06 +00:00
Vlad Tsyrklevich
8b2ec2aae4 Make TaskMemory a child class of ProcessMemory
Currently TaskMemory re-implements a number of Read* routines that are
implemented in a platform-independent way in ProcessMemory with access
to a single platform-specific ReadUpTo method. Implement the ReadUpTo
method for TaskMemory and subclass it from ProcessMemory to inherit the
remaining methods.

The ProcessMemoryTests didn't work on macOS because MultiprocessExec
can not access the child process' task port without root privileges or
the task_for_pid entitlement. Create an adaptor class for those tests to
use MachMultiprocess so that the child process sends its task port to
the parent.

Bug: crashpad:263
Change-Id: Id8e1788a74fe957f05703a5eb569ca3bf9870369
Reviewed-on: https://chromium-review.googlesource.com/c/1387265
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-12-20 19:44:31 +00:00
Vlad Tsyrklevich
7018a80b36 Simplify test set-up
Use platform independent helpers to simplify initializing a
ProcessMemory object in this test.

Bug: crashpad:263
Change-Id: Id0f9e006f6dbaca31453803b8c790a6832e855e5
Reviewed-on: https://chromium-review.googlesource.com/c/1387264
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-20 17:45:01 +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
Nathan Rogers
ffd666e16c fuchsia: Update Paths::Executable documentation
Update the "...namespaces.md..." link to its current URL.

Change-Id: Ic30c6be5dba4f531e5b8a55af37555626398df5a
Reviewed-on: https://chromium-review.googlesource.com/c/1381777
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-12-19 23:02:29 +00:00
Vlad Tsyrklevich
f2a07982ff Change edge case handling in ReadCStringInternal
Currently, TaskMemory::ReadCStringInternal() treats the
ReadCStringSizeLimited(size=0) case by returning an empty string;
however, that is inconsistent with the documentation for that function
and the equivalent implementation in ProcessMemory. The comment for the
size parameter is: "The maximum number of bytes to read. The string is
required to be `NUL`-terminated within this many bytes." My
interpretation is that the ProcessMemory behavior is correct in failing
on size=0 as a NUL can never be read.

ReadCStringSizeLimited() is only used with a possibly null size in
MachOImageReader::ReadDylinkerCommand(). In that case we read the
dylinker_command string, which appears to also be verified to be a
non-zero length null terminated string in load_dylinker() in
bsd/kern/mach_loader.c so we shouldn't hit this case in the wild.

Bug: crashpad:263
Change-Id: I2bd9c0ce3055154a98afdd19af95bb48d05f05a3
Reviewed-on: https://chromium-review.googlesource.com/c/1384448
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-19 21:42:23 +00:00
Joshua Peraza
83867d5234 linux: Add ScopedPrSetDumpable
Bug: 914246
Change-Id: I529467e92a5cbc2a372f4c12234cfd3af8ddfe0a
Reviewed-on: https://chromium-review.googlesource.com/c/1382598
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-12-18 17:45:43 +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
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
9b6dde9101 [fuchsia] remove Fuchsia-specific code in MoveFileOrDirectory
ZX-1729 has been fixed upstream

Change-Id: Ia9c55b13169db650eb4ca0562434ae19a6f44eaf
Reviewed-on: https://chromium-review.googlesource.com/c/1366638
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2018-12-06 23:34:54 +00:00
Scott Graham
ad788280e4 fuchsia: Disable HTTPS tests to avoid (unavailable) dependency on BoringSSL
Bug: crashpad:266
Bug: fuchsia:DX-690
Change-Id: Ica6c2d6d345cbda17fd67de69e7c770389808f63
Reviewed-on: https://chromium-review.googlesource.com/c/1340743
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-16 21:19:24 +00:00
Joshua Peraza
651af7583b win: use zx format specifier instead of a cast
Change-Id: I14fac035ecafaa5d2459b63a070f701389160ad4
Reviewed-on: https://chromium-review.googlesource.com/c/1323772
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-11-07 19:33:00 +00:00
Joshua Peraza
e287a3ab12 win: fix mismatched format macros
When building in Chromium:
../../third_party/crashpad/crashpad/util/process/process_memory_win.cc(95,74):  error: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
"range at 0x%llx, size 0x%llx completely inaccessible", address, size);
~~~~                                    ^~~~
%zx
../../third_party/crashpad/crashpad/util/process/process_memory_win.cc(103,72):  error: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
"start of range at 0x%llx, size 0x%llx inaccessible", address, size);

Change-Id: I820f0afee28d1220ca400780eac61de05bde10ef
Reviewed-on: https://chromium-review.googlesource.com/c/1323771
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-11-07 18:51:52 +00:00
Joshua Peraza
bf10ed0a69 posix: use threadsafe gtest death test for ScopedGuardedPage
Also update gyp to build it.

Change-Id: I859c552b9cfc41f531ffb04fe6d6730dbd0e8fed
Reviewed-on: https://chromium-review.googlesource.com/c/1319269
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-06 21:12:54 +00:00
Vlad Tsyrklevich
a9be1b1403 Add ProcessMemoryWin and re-factor tests
Currently, ProcessMemory is only implemented for Linux and Fuchsia.
Implement the interface for Windows as well and re-factor tests to
support it, mostly this consists of using a new ScopedGuardedPage class
instead of ScopedMmap in the ProcessMemory tests.

BUG=crashpad:262

Change-Id: I1b42718972be5ad838d12356d09f764053f09e4f
Reviewed-on: https://chromium-review.googlesource.com/c/1278829
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-05 21:33:35 +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
Joshua Peraza
e00c42e63f linux: use offset of d_name to get size of dirents
Dirents with short names can have a d_name that fits inside padding at
the end of Dirent64.

Change-Id: I18057dad01f5a7d4a063028ca9f61fbe89ae7fc0
Reviewed-on: https://chromium-review.googlesource.com/c/1310413
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-10-31 20:37:03 +00:00
Braden Kell
5dd094381c [sysinfo] Convert sysinfo ioctls to FIDL calls
Bug: fuchsia:ZX-2842

Change-Id: Ib84b4319d3bb07a2c68bc2ff0d63e49fa65eb2b5
Reviewed-on: https://chromium-review.googlesource.com/c/1292237
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-10-29 20:24:55 +00:00
Scott Graham
237c5ebdf3 fuchsia: Fix include_dirs for host Mac build
Change-Id: I157fe2ab95d0b152ef5cc09cd0b6e56649c9f727
Reviewed-on: https://chromium-review.googlesource.com/c/1277777
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-10-11 23:18:47 +00:00
Scott Graham
1c09361c2c fuchsia: Let util build in Mac-host builds
Some of the minidump functionality is going to be used in Fuchsia in
host side tools (in zxdb, the debugger). This fixes the Mac-host build
of util.

Change-Id: Ifeb3bd9c7fa29c99a272c97c2813b9c201ddfe88
Reviewed-on: https://chromium-review.googlesource.com/c/1277774
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-10-11 22:04:40 +00:00
Scott Graham
1b4fdd0fd0 fuchsia: Re-enable HTTPS transport, but disable tests
The HTTPS tests are flaky on Fuchsia bots, so TLS transport was disabled.
However, a different CHECK fails in prod when a crash is attempted to be
uploaded via an 'https' url. So for now, re-enable the https transport,
but disable the https tests that were flaky, so they can be debugged
separately.

Additionally, there was a small error in
21edfd3c3a
that wasn't caught because these tests were disabled; fix the path to
test server certs on Fuchsia.

Bug: fuchsia:DX-382

Change-Id: I4ad0649ecb6d0644b1dfcf08bbb097d3a0cd40d0
Reviewed-on: https://chromium-review.googlesource.com/c/1265197
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Francois Rousseau <frousseau@google.com>
2018-10-05 18:16:11 +00:00
Francois Rousseau
ce122b644c [util/net] add error message to scheme check
* instead of just 'Check failed: scheme == "http"', we will have something
like 'Check failed: scheme == "http". Got 'https' for scheme in 'https://for.bar''
* clangfmt on file

Bug: fuchsia:DX-514
Change-Id: I043af7281d7f99ed5641c87920d806e340a38dea
Tested=`out/Debug/crashpad_util_test` and Fuchsia logs
Reviewed-on: https://chromium-review.googlesource.com/c/1262140
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-10-04 20:51:53 +00:00
Hans Wennborg
7786acf0d7 win: move string_number_conversion_test asan/dll disabling into the win clause
This fixes the upstreaming of https://chromium-review.googlesource.com/c/chromium/src/+/1113664

Bug: chromium:856174
Change-Id: I88cf6aeecef60e4eaf5c14dc9a66f0409255ccac
Reviewed-on: https://chromium-review.googlesource.com/1245481
Commit-Queue: Hans Wennborg <hans@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-09-26 17:01:52 +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
9ae453628f android: handle RELRO sharing by the Chromium linker
Bug: crashpad:253
Change-Id: I7d6b1bfebe621d90a4b69dd44073abf471fa822c
Reviewed-on: https://chromium-review.googlesource.com/1232293
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-09-20 16:30:44 +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
9dcf4ab23e arm/linux: Fix build after a5214472
The build broke because x30 was used instead of r14 in place of LR
which gcc doesn't recognize when building for 64-bit ARM. gcc does
recognize LR for 32-bit ARM, however, so revert to that since it's
more readable.

Also, de-duplicate saving of FP/IP which are synonyms of r11/r12,
saved above.

Change-Id: I8ae28f430cc3c47f4e4cf3679383ed5b94fadd2e
Reviewed-on: https://chromium-review.googlesource.com/1217483
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-09-10 21:20:32 +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
Maksim Sisov
a521447214 Use x30 register instead of LR, which GCC doesn't seem to understand
When tested with GCC 6, it couldn't to understand LR register.
Thus, use x30 instead.

The error this patch fixes is the following:

Error: operand 1 must be an integer register -- `str LR,[x0,#0x1b8]'

Test: compile for aarch64
Change-Id: Icf1199254c6a29f72b6d2fa7940e1f33259a728b
Reviewed-on: https://chromium-review.googlesource.com/1213125
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-09-10 11:29:11 +00:00
Joshua Peraza
30b8c0dc2a win: disable string_number_conversion_test for asan/dll
Upstreams:
https://chromium-review.googlesource.com/c/chromium/src/+/1113664

Change-Id: I8c3000eebf2be54e8d693bf08a6e92b68c1d5d72
Reviewed-on: https://chromium-review.googlesource.com/1195567
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-08-29 16:44:43 +00:00
Joshua Peraza
0204fbd38b posix: Make DoubleForkAndExec accept an envp parameter
This will be useful to allow setting variables such as CLASSPATH or
LD_LIBRARY_PATH without modifying or depending upon the application's
current environment.

Bug: crashpad:30
Change-Id: I34f31bcc397e51d789b48eb654d80f992a719074
Reviewed-on: https://chromium-review.googlesource.com/1194399
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-29 14:41:08 +00:00
Will Harris
2c6c0935e2 Fix an implicit 64-bit to 32-bit conversion.
../../third_party/crashpad/crashpad/util/misc/metrics.cc(66,35):  error: implicit conversion loses integer precision: 'crashpad::FileOffset' (aka 'long long') to 'base::HistogramBase::Sample' (aka 'int') [-Werror,-Wshorten-64-to-32]
      "Crashpad.CrashReportSize", size, 0, 20 * 1024 * 1024, 50);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also, remove some unneeded static_casts.

BUG=588506

Change-Id: I0c12079db173e44c07e2f1d02322747cb2d69535
Reviewed-on: https://chromium-review.googlesource.com/1184227
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-08-24 17:03:01 +00:00
Mark Mentovai
f8b0538406 fuchsia: Don’t require test certificate setup for disabled TLS tests
This is a follow-up to e6f26587e435.

Bug: DX-382
Change-Id: I3116ea5dd2eca33961465d62c9200aa8dd1baf5d
Reviewed-on: https://chromium-review.googlesource.com/1173339
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-08-13 23:35:08 +00:00
Mark Mentovai
e6f26587e4 fuchsia, net: Disable TLS, not currently working for in-Fuchsia tests
Bug: DX-382
Change-Id: I06a0a71c32d8d28d30b1add8a2bd57f1d6462463
Reviewed-on: https://chromium-review.googlesource.com/1171984
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-08-13 20:00:55 +00:00
Jeremy Apthorp
f540abb506 Treat response codes in [200..203] as successful
Some crash recorders respond with non-200 2xx responses on success, e.g.
HockeyApp which responds with 202 Accepted.

Change-Id: I40de12155b44f7638a1c726090657938e3b1b557
Reviewed-on: https://chromium-review.googlesource.com/1167793
Commit-Queue: Jeremy Apthorp <jeremya@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-09 23:53:29 +00:00
Mark Mentovai
2906581f10 win: Fix GYP build of http_transport_test_server
The C++ http_transport_test_server was added in 439ba730c5ae and the
missing GYP build description was corrected in 0e144fb9aeff, but this
wasn’t complete for Windows. ws2_32.lib was missing.

Bug: crashpad:227
Change-Id: I2a0810468f857a02ad1a997c569eee6d9c05c7da
Reviewed-on: https://chromium-review.googlesource.com/1167210
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-08-08 15:22:01 +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
063ff78a25 Use __aarch64__ instead of __arm64__
__aarch64__ should always be defined for 64-bit ARM, while __arm64__
only sometimes is.

Change-Id: I46a6469d8f5e74ad79b6ded51a809fbf88e5170a
Reviewed-on: https://chromium-review.googlesource.com/1151541
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-07-26 16:37:25 +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
2f3a8b8f72 Add CrashSkippedReason::kPrepareForUploadFailed
Bug: crashpad:30
Change-Id: I763c30e261c315b45860c8672d9cffbba4714f32
Reviewed-on: https://chromium-review.googlesource.com/1148895
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-07-24 20:37:18 +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
1e504474a0 linux: Get exe name from main arguments
When building in chromium, the test is linked into the crashpad_tests
target instead of crashpad_util_test.

Change-Id: I4e0f6b9956f191ebac10f0aaa3812e30885a4e0a
Reviewed-on: https://chromium-review.googlesource.com/1131688
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2018-07-10 16:37:14 +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
Brett Wilson
639cba075c Use new Fuchsia kernel API to suspend threads.
We are transitioning to a token-based API and will be removing the
old one.

Changes to use a thread state wait rather than reading the registers in
a loop to determine when the thread is actually suspended.

Change-Id: I4b015bb0fc74b15177304a62be6c1d9a59b45c80
Reviewed-on: https://chromium-review.googlesource.com/1100170
Commit-Queue: Brett Wilson <brettw@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-06-14 18:00:59 +00:00