636 Commits

Author SHA1 Message Date
Jan Wilken Dörrie
a98ee20e57 [crashpad] Prepare crashpad for base::string16 switch
This change prepares crashpad for the upcoming switch of base::string16
to std::u16string on all platforms. It does so by replacing Windows-only
instances of base::string16 with std::wstring, and using appropriate
string utility functions.

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

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

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

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

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

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

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

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

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

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

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

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

Includes:

Update mini_chromium to e0008f2714a76c7f2a3854fa75774427a886d6b9

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

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

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

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

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

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

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

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

More information can be found at go/cros_is_linux_os_linux

BUG=chromium:1110266
TEST=manual build

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

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

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

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

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

This change was made mostly mechanically by:

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

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

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

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

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

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

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

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

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

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

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

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

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

This is mostly a lot of CPU context shuffling.

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

This is mostly a lot of CPU context shuffling.

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

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

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

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

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

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

Roll mini_chromium ae14a14ab..cd26c5101

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

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

The Windows and Fuchsia builds are broken, so…

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

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

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

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

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

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

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

Bug: chromium:1050178
Change-Id: I83581d05c5ed3e25a237d1ce4a27c45755a3ab3c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2231525
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-06-05 02:29:11 +00:00
Joshua Peraza
294d233ca0 elf: adjust small DT_STRTAB addresses by load bias
Change-Id: I7ffbd2be0800aedad8b5c4b6982379e5485f1bc8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2229114
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-04 22:42:57 +00:00
Joshua Peraza
86c28287d2 linux: add section header string table to test module
While ELF allows the section header string table to be missing,
it is required by Android API 26+.

Bug: chromium:1050178
Change-Id: I124e4356bda9c628f76944729a6c0c5e7a52561a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2227129
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-06-02 20:19:46 +00:00
Joshua Peraza
686852d9d8 linux: update test expectations
Android 9+ sets the executable's dynamic array
address in the link map.

Improve tests to verify that the dynamic array
address in the link map matches the address in the
executable.

Bug: chromium:1050178
Change-Id: I4c938f804092c8f35578389a7e7d7267144ad80c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1967972
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2020-06-01 23:25:05 +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
Ian Barkley-Yeung
8bd5e53777 BUILD: Look at current_cpu instead of target_cpu
Fixes build error where fuchsia_arm64 builds were failing because they
picked up linux x86 code.

Bug: None
Change-Id: I48a7bc92490604fd2a59cb4d36421cb76f579224
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2172636
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Ian Barkley-Yeung <iby@chromium.org>
2020-04-29 21:21:57 +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
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
Mark Mentovai
7fa69e7e43 win: Remove disabled and flaky end-to-end tests
The “and not memory after range” follow-up to the “extra memory range
captured” test is very flaky in debug builds
(https://ci.chromium.org/p/crashpad/builders/ci/crashpad_win_dbg/388),
and occasionally flaky in release builds too
(https://ci.chromium.org/p/crashpad/builders/ci/crashpad_win_rel/363).
As with the already-disabled “extra memory removal” test, it’s likely
that Crashpad is discovering a pointer that references the memory
immediately beyond the intended range, and capturing that too. Unless
the environment is very tightly controlled, it’s difficult to prevent
valid memory from being pointed to, and thus to guarantee that Crashpad
won’t capture a particular block of memory.

These are probably never going to be fixed. The flaky tests are removed.

Bug: crashpad:101
Change-Id: I629ed8ce3c901507689218baaa102d8737db3f5b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2150055
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2020-04-15 16:52:45 +00:00
Mark Mentovai
3c44556cf1 Replace ScopedClearErrno with ScopedClearLastError
Includes:

Update mini_chromium to bbf1307928bb7a9d1eda6be576283c8093b2775b

bbf1307928bb Replace ScopedClearErrno with ScopedClearLastError

Change-Id: I8eabb5f62a21c5b30c5b07face2a6afcf10bb82b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2145829
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-04-14 00:59:33 +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
Mark Mentovai
61a4f3d7d6 mac: kern.nx is not present in 10.14.5 et seq, but NX is always enabled
This updates the comment from d3859d91fde0, which referred to 10.14.4 as
the OS version where kern.nx stoppoed working. Testing indicates that
kern.nx works in 10.13.6 17G12034 and 10.14.4 18E226. It does not work
in 10.14.5 18F132 or 10.15.4 19E266.

Bug: crashpad:295
Change-Id: Id2f222700fb626de707d60980fedbd79e62990e6
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2127566
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2020-03-30 17:08:24 +00:00
Mark Mentovai
d3859d91fd mac: kern.nx is not present in 10.14.4 et seq, but NX is always enabled
Bug: crashpad:295
Change-Id: Id1de68d402d229b43fab5e8d15b0fe23c618ce08
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2119645
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
2020-03-26 01:07:10 +00:00
Justin Cohen
faae6470cf [ios] Bring up first draft exceptions snapshot.
Gather most of the necessary information for the 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 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: Iae4af436cddabd2302689b76c8a4574eb8e48c0e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2098744
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-03-25 20:36:06 +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
Justin Cohen
311a5a2fdd Fix chromium build.
Chromium's sources_assignment_filter broke the build.

Change-Id: I741ce06feafcfe7abd69f65ad9c871b66452dd83
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2117368
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2020-03-24 22:08:52 +00:00
Justin Cohen
4e2a190ad6 [ios] Bring up first draft thread and memory snapshot.
Gather most of the necessary information for the thread 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.


Change-Id: I80ba323cb6a59ac0dd1bba9150d047ba83cc4dad
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2085572
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
2020-03-20 17:26:49 +00:00
Justin Cohen
1d75af9bf5 Fix bad iOS module casting.
Change-Id: I0f8dcd867c56c4b1476c23d280e08448d2e90795
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2097177
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2020-03-10 20:59:27 +00:00
Justin Cohen
b109e4ce38 [ios] Bring up first draft process and module snapshot.
Gather most of the necessary information for the module 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 module_snapshot may end up in a
   different file completely, but until we pick a
   serialization/deserialization method, keep it in module_snapshot_ios.

Change-Id: Ie80c739c167634520d13ec920a29a80116aa3bfe
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2079196
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2020-03-05 15:42:35 +00:00
Jinke Fan
e1b3bd11cd Add support for Hygon Dhyana CPU
This patch is used to add support Hygon Dhyana x86
vendor id (HygonGenuine).

More details can be found on:
http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cn

Change-Id: I53445a8a63421811401b6a6a40e664d2600a3ec8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1640959
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-03-03 18:12:33 +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
0c20aeabd3 [UBSan] Temporarily disable UBSan for snapshot and minidump
UBSan was reporting reference binding to a misaligned address in Fuchsia.
Disable UBSan for this target for now just to silence the runtime
warnings, then come back and fix them.

Bug: fuchsia:46805
Change-Id: Ic5d9b35161b6d998f1ff50eb8e978c44aff9b4ef
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2068051
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2020-02-21 21:20:59 +00:00
Roland McGrath
22701bb0e4 fuchsia: Use zx_system_get_version_string
The new API replaces zx_system_get_version and is simpler.

Bug: fuchsia:45640
Change-Id: Ibc47703aba0e87e55265608b517e5953eada182f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2063908
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2020-02-19 04:43:35 +00:00
Brian Sheedy
ff1036aa60 Remove failing thread suspend DCHECK
Removes a failing DCHECK in process_reader_win.cc caused by a race
condition with a thread being injected into a process whose existing
threads are already suspended.

Bug: chromium:1007013
Change-Id: Ifa569220b28e8e2e5dfa6c32b2be4c57f61076b3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2047803
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
2020-02-10 20:12:15 +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
Vitaly Buka
4367e9df17 Increase kAllowedOffset for non-optimized build
"init_stack_vars = true" inserts additional instructions which
usually removed by optimization if code does not rely on undefined
behaviour of uninitialized variables.
However in non-optimized build these instructions may still be present.

Fixing https://ci.chromium.org/p/chromium/builders/ci/Win10%20Tests%20x64%20%28dbg%29/12597
Related patch: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1949846

Bug: chromium:1030261
Change-Id: Ib05fa8580d4b0206f70e2dfac5e0f3a3d4389f95
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1995823
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
2020-01-13 19:08:22 +00:00
Tomasz Śniatowski
0b8741b074 Remove redundant semicolon in cpu_context_linux.h
Fix a -Wextra-semi warning in Clang when building crashpad for MIPS.

Change-Id: I53893c815de74d2503acdce24708e29096f4b0aa
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1997103
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Tomasz Śniatowski <tsniatowski@vewd.com>
2020-01-13 17:32:22 +00:00
Vlad Tsyrklevich
c2978022d1 Update comment to match current state of MemorySnapshotGeneric
MemorySnapshotGeneric is now used on all platforms as it uses
ProcessMemory instead of templating to use a platform-specific
ProcessReader* class.

Change-Id: Ib0b6db0fac184c558f1c76a584db92e4804dfe99
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1977640
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2019-12-20 17:29:59 +00:00
Mark Mentovai
cba3dabf24 Add .gitattributes, setting “text eol=lf” or “binary” for all files
This should prevent accidental "\r\n" line endings from being introduced
again, as happened in 359fc4a1336d, fixed by 31470459b624.

Also includes:

Update mini_chromium to 0512d42698bfb47f2016ac627177c22d22b983d4

0512d42698bf Add .gitattributes, setting “text eol=lf” for all files

Change-Id: Id84c014914fec66632006ed364e2b14b4f1c175c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1953807
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2019-12-06 19:07:12 +00:00
Vitaly Buka
e01fb92aa9 Fix #elif in crrev.com/c/1949846
I was editing the patch in gerrit and looks like it undone !defined
change and I landed wrong version.

Bug: chromium:1030261
Change-Id: Ib645839bac5450fe55ecd9f3a38155022b7f6c13
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1951624
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
2019-12-04 21:58:57 +00:00
Vitaly Buka
9a312ddff5 Increase kAllowedOffset for non-optimized build
"init_stack_vars = true" inserts additional instructions which
usually removed by optimization if code does not rely on undefined
behaviour of uninitialized variables.
However in non-optimized build these instructions may still be present.

Bug: chromium:1030261
Change-Id: I85d1d0a240dcd1c29c6ff148e88d572b5dcc81d1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1949846
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
2019-12-04 19:25:59 +00:00
Scott Graham
0208c1a175 fuchsia: Don't capture incorrect/unreasonably large stacks
In a stack overflow test from the Fuchsia tree, an intentional crash was
being induced that at the point it was reported to Crashpad resulted in
a stack pointer outside of the stack. This caused two problems:

- Crashpad attempted to capture that whole "thing" which could have been
  anything, and in the failing test was a 1G guard region
- The whole wrong thing could be very large, resulting in OOM when
  trying to write the minidump, which was the symptom of the bug.

Don't attempt to continue of SP isn't at least in a mapping, and don't
capture too-large regions for the stack as nothing useful can come of
that anyway.

New test added: ProcessSnapshotFuchsiaTest.InvalidStackPointer.

Bug: fuchsia:41212
Change-Id: Ifb48fd8b4b5b2f0cf10ab97e01dbd8b842368775
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1912942
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Francois Rousseau <frousseau@google.com>
2019-11-13 00:26:24 +00:00
Mark Mentovai
cea103fb7d mac: Fix ProcessTypes.DyldImagesSelf with 10.14 SDK on 10.12
The current 10.14 SDK is numbered 101404, which is greater than
MAC_OS_X_VERSION_10_14 (101400). That was causing the test to
unintentionally fall into the “unlisted SDK” branch of the #if cascade
due to testing SDK <= MAC_OS_X_VERSION_10_14. This is corrected by
testing SDK < MAC_OS_X_VERSION_10_15 instead.

Bug: chromium:1016314, crashpad:310
Change-Id: If062e8fca92ae105924addf10c3e2fde162448cf
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1872636
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-10-23 20:36:07 +00:00
Joshua Peraza
d8f85829b0 linux: fix split stack test
Previously, page_addr sometimes ended up being in the current stack
frame, causing a segfault when write protecting it. Reach another
page up the stack and add an extra stack page for wiggle room.

The test consistently fails on linux-chromeos bots:
https://ci.chromium.org/p/chromium/builders/try/linux-chromeos-rel/373920

Change-Id: I5e2aa8c54555ef559251a14b0310a24131c9f17a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1857500
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-10-12 18:39:31 +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
Mark Mentovai
2fb4e9e6a4 mac: Update the process_types version of dyld_all_image_infos for 10.15
macOS 10.15 (“Catalina”) introduces a single new field to its
dyld_all_image_infos structure, and uses structure version 16.

macOS 10.13 and 10.14 were documented in <mach-o/dyld_images.h> as using
structure version 16, but they actually use version 15. They should have
used version 16, as they do use a structure expanded from macOS 10.12,
which also uses version 15. Previously, process_types was true to the
documentation, but now that this is known to be incorrect, it’s been
revised to reflect reality. Because two variants of the version 15
structure exist, run-time OS version detection is used to disambiguate.

Bug: crashpad:310
Test: crashpad_snapshot_test ProcessTypes.DyldImagesSelf (10.15 SDK)
Change-Id: Ibc82b6a73809949f4bbf416ece7aa955b627c573
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1852109
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2019-10-10 21:59:24 +00:00
Scott Graham
b71f61f8e3 fuchsia: Defer initialization of memory map
This allows partial reading of the current process (e.g. modules or
CrashpadInfo), even though the memory map read (and so thread retrieval)
will fail if ProcessSnapshotFuchsia is used on the current process.

This is a follow up to
db6f51d3fc
which broke the CrashpadInfoClientOptions.* tests.

Bug: fuchsia:34598
Change-Id: Ifa17b4dbefcd198ff67ecea91f946cfa2439ca4c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1776936
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2019-08-30 15:50:34 +00:00
Joshua Peraza
7b5a55c3b1 Move whitelist ownership to ProcessSnapshotSanitized
Change-Id: Ie57117229520e52aeff83d0cbf95057690894e5b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1773772
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-08-29 21:30:02 +00:00
Scott Graham
db6f51d3fc fuchsia: Check results of Initialize() subcalls in ProcessReaderFuchsia
From looking at some syzkaller logs, the earliest error seems to be

  [...ERROR memory_map_fuchsia.cc:47] zx_object_get_info ZX_INFO_PROCESS_MAPS: ZX_ERR_BAD_STATE (-20)

which might be caused by a failure to suspend. That error causes
ProcessReaderFuchsia's memory_map_ Initialize() to fail, but that was
mistakenly being ignored. Later calls then fail as well.

While we're here, also check a couple other Initialize()s that were
sometimes triggering later on.

Bug: https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=34598
Change-Id: I9f9d7315f504e6ec69308add20e2737ce5c5f644
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1763028
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2019-08-21 00:18:51 +00:00
Joshua Peraza
3a6c6012ba linux: override exception thread ID
When a crash dump request is received over a socket, the message
includes a stack address of the thread requesting the dump. This can
be used to override the ExceptionInfo's thread ID which may be
incorrect in the handler's PID namespace.

Bug: crashpad:286
Change-Id: I053cf709c5eeefb73b31328f16a806510e1bd35d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1759280
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-08-19 21:48:20 +00:00
Scott Graham
efaebfc482 fuchsia: Capture from SP (+slop) to stack base, rather than entire stack
Stack mappings can be enormous for some processes dwarfing all other
data and making the .dmp useless. It isn't useful to capture beyond the
stack pointer, so grab only from the stack base to the stack pointer.

In the default config (safestack enabled), this isn't a major problem.
However, Chromium has safestack disabled, along with a large stack size,
so dumps with many threads become very large.

Bug: https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=6425
Bug: chromium:821951
Change-Id: Iebefc5fe43e3d1bc4d8b66c107d3ab8ae5b3f68b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1758702
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Francois Rousseau <frousseau@google.com>
2019-08-19 17:41:59 +00:00
Casey Dahlin
64399c514f Implement Exception context for minidump
Bug: crashpad:10
Change-Id: I90d72d813da11d25c1ed13a51daacec9b0ad4a0f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1753063
Commit-Queue: Casey Dahlin <sadmac@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2019-08-15 20:52:54 +00:00
Vlad Tsyrklevich
5a4c2f2b83 Plumb in support for ProcessMemorySanitized
A previous change added a ProcessMemorySanitized class, in this change
plumb support for ProcessMemorySanitized into ProcessSnapshotSanitized.
This involves reading whitelisted regions using the a new field in the
SanitizationInformation struct and returning an initialized
ProcessMemorySanitized object from ProcessSnapshotSanitized::Memory().

Bug: crashpad:263, chromium:973167
Change-Id: I121c5a584a1704ad043757c113099978a9ec2f4e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1754737
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2019-08-15 20:06:14 +00:00
Peter Collingbourne
6225d78906 Don't use a regex to test the CPU vendor string.
This test will break if there is an unusual character in the vendor
string. Moreover, std::regex is banned in Chromium so the test is
blocking the roll.

Probably all that can meaningfully be tested here is that the vendor
string is non-empty, so do that instead.

Change-Id: I60ea52e1b52c4d8e467518d03088815dcb5e3fce
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1756327
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Collingbourne <pcc@chromium.org>
2019-08-15 17:31:04 +00:00
Vlad Tsyrklevich
5a0e18e417 Refactor 'whitelist' -> 'annotations whitelist'
In preparation for an upcoming change that will introduce a second
whitelist (for memory ranges), rename variables/functions to explicitly
reference the annotations whitelist.

Bug: chromium:973167
Change-Id: I1bf232e370990571230a247f9d9022d56ba4fedf
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1752361
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-08-14 23:22:43 +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
Istvan Romai
e163efb372 Added CPU revision implementation for ARM64
Change-Id: I42e6c76715dfd44fa87c8bbd56b8903f76cef87c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1655468
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-07-23 18:42:19 +00:00
Joshua Peraza
c05bd0574b include missing header
Change-Id: I64d248aecbf894da88ea95d70320d91368967832
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1702845
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-07-15 22:31:56 +00:00
Joshua Peraza
cc8fe9ddab Implement ProcessSnapshotMinidump time getters
Bug: crashpad:10
Change-Id: I0e1449017c60c237eef50818e33cb70e3bfe9b23
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1697057
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-07-11 20:46:22 +00:00
Vlad Tsyrklevich
0f2e2064a1 Disable ProcessReaderLinux.ChildWithSplitStack under ASan
Change-Id: Ibaee389e64d6e54133a4fb7f4d05cfde0a529821
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1684673
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-07-02 06:09:47 +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
Clark DuVall
e5abe92b2e Add user minidump stream support for ELF
This is very similar to the windows implementation in
module_snapshot_win.cc.

Bug: crashpad:95
Change-Id: I3858e8bb0009c95395bfb7ca3855c3d937fd49d5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1641588
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-06-11 17:20:05 +00:00
Clark DuVall
d85f898a69 Refactor MemorySnapshotGeneric to use ProcessMemory instead of ProcessReader
Also remove MemorySnapshotWin since the code is identical to
MemorySnapshotGeneric now.

Bug: crashpad:95
Change-Id: I9a631f8eb206dd72a69158021db87e8db41c5913
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1642148
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
2019-06-10 20:34:12 +00:00
Adam Kallai
c5f296c044 Disable CPUX86SupportsDAZ unit test on Windows ARM64
This unit test is related to X86 CPU Family, it could be disabled on ARM64.

Bug: None
Test: Run crashpad_tests, it's disabled on ARM64
Change-Id: I7ebe5dd7d8964e8efd0ebcd96944e5981f8b7606
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1634772
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-06-03 13:51:37 +00:00
Julie Hockett
3e5da31f90 Remove non-source files from library
Recent changes to GN mean that non-source files in final targets are an
error. Since they were ignored previously, this should be an NFC.

See crbug.com/gn/77 for details.

Change-Id: Ifc845a3b3b044e71ab4086ab19748adb7b4d4d08
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1632676
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-05-28 19:08:16 +00:00
Scott Graham
ee1d5124a2 Fix incorrect range checks in elf image note reader
Overflows before and after padding could cause the max note size check
to be evaded.

Bug: chromium:967228, chromium: 967257, chromium:967223
Change-Id: I499a273e76e78529fc59ddcb74055be6d01fa2cb
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1631635
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2019-05-28 18:23:11 +00:00
Scott Graham
daf9f5669e Fix unchecked allocation size of in fuzzer note reading
This fixes a fuzzer-only bug, and modifies the note API so that it can
no longer request infinitely sized notes.

Bug: chromium:966303
Change-Id: I97b9ca6774d3101560caddf2f9b0a8d7ecf7c2e2
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1628675
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-05-24 20:20:27 +00:00
Scott Graham
122363ccae Fix compile for Linux 32b fuzz target
This code was previously not enabled, but was turned on recently.
However, there's no CQ check for 32 bit code.

Bug: chromium:966292
Change-Id: I4a3205d8517575e25d3e525f247ad45a906c3e25
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1627679
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2019-05-23 17:37:08 +00:00
Julie Hockett
7b01557606 Remove non-source files
Recent changes to GN require only buildable files to be included in
sources. See crbug.com/gn/77 for additional details.

Change-Id: Ie3012fa5ae68a0886819647435fecb1d9c3d7aea
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1623149
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
2019-05-21 21:04:01 +00:00
Jonathan Metzman
18aa41d48c [libFuzzer] Enable fuzz targets to build in Chromium
Enable building elf_image_reader_fuzzer in Chromium.
Rename it to crashpad_elf_image_reader_fuzzer so that its clearer
where the fuzzer comes from.
Import chromium's fuzzer_test definition when building in Chromium and
make sure fuzzer is only built on Linux since it breaks fuzzer build
on Win (and maybe Mac?).

Bug: 950093
Change-Id: I8afc104d26871311b04931b82a1600614a81bfc8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1597091
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-05-06 22:02:56 +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
Casey Dahlin
93366d782a Make OSVersionFull work for SystemSnapshotMinidump
Bug: crashpad:10
Change-Id: I98c630d4c9c9ba4b5a4d7f9605102827bf185cc3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1575663
Commit-Queue: Casey Dahlin <sadmac@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-23 00:08:42 +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
Peter Wen
a7859e9bc6 Add ExceptionSnapshotMinidump.
Implemented all of the interface except Context().

Bug: crashpad:10
Change-Id: If76e539fd7b995da50f83e02f095f05537f5572a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1567489
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Casey Dahlin <sadmac@google.com>
2019-04-17 17:19:01 +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
Francois Rousseau
b0373799ba [fuchsia] fix module names for executables and loadable modules
On Fuchsia, executables and loadable modules don't have a name at build
time so we use "<_>" as module name to index their symbols on the crash
server. We need to use the same dummy value at run time.

Bug: fuchsia/DX-1193
Tested: `fx run-test crashpad_test`

Change-Id: Ie926a6d26cb52679ccfac767db098c9fbfd21dd8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1548230
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2019-04-02 22:42:17 +00:00
Peter Collingbourne
94dc7eb437 Collect abort messages on Android.
As of Android Q, the android_set_abort_message() function copies the
abort message into a mapping with a specific name that starts with a magic
number. This makes it possible for Crashpad to collect the abort message
by looking for the mapping with this name in procmaps and checking for the
magic number. The abort message is stored in a process annotation named
"abort_message".

Test: No regressions in build/run_tests.py on devices running P and Q
Test: Patched into Chromium; manually verified that HWASAN crash report appears in minidump
Bug: crashpad:287
Change-Id: I23c4d9e11015c84341de2d2e47e38a1eec508a36
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1544875
Commit-Queue: Peter Collingbourne <pcc@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-03-29 22:46:12 +00:00
Joshua Peraza
1bb8ca4059 Silence some warnings
These warnings create a lot of noise in the Android logcat

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Includes:
Update mini_chromium to 737433ebade4d446643c6c07daae02a67e8deccao

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bug: 896019

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

CQ-DEPEND=CL:1278830

BUG=crashpad:262

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

BUG=crashpad:262

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

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

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

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

Reason for revert: Fuchsia has been transitioned to spsr.

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

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

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

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

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

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

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

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

Reason for revert: arm64 lto build

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

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

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

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

Also Android's time_t is a signed type.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bug: crashpad:10
Change-Id: I727eeef5770430253a45cd046a66488f743ac25a
Reviewed-on: https://chromium-review.googlesource.com/c/1285033
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-10-17 17:34:11 +00:00