394 Commits

Author SHA1 Message Date
Mark Mentovai
6da9708e7c doc: Fix Doxygen errors
Change-Id: I5d5abf7b7eabe269a7c7b4d305a67fe910c887fd
Reviewed-on: https://chromium-review.googlesource.com/446480
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-23 01:43:40 +00:00
Mark Mentovai
c1af20f1aa metrics: Consistently comment about enums used for metrics
BUG=crashpad:100

Change-Id: I9ed0f260b4c92e7a706418f58c3db1ae027a04ab
Reviewed-on: https://chromium-review.googlesource.com/446557
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-23 00:13:04 +00:00
Mark Mentovai
f34ed66b93 metrics: Record handler lifetime milestone events
It could be useful to put our existing Crashpad.HandlerCrashed metrics
into context by getting a sense of handler starts, clean exits, and
other types of exits.

BUG=crashpad:100

Change-Id: I8982075158ea6d210eb2ddad678302e339a42192
Reviewed-on: https://chromium-review.googlesource.com/444124
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-22 18:48:12 +00:00
Mark Mentovai
0c322ecc3f Use zlib to gzip-compress uploads
This adds zlib to Crashpad. By default in standalone Crashpad builds,
the system zlib will be used where available. A copy of Chromium’s zlib
(currently a slightly patched 1.2.11) is checked out via DEPS into
third_party for use on Windows, which does not have a system zlib.

zlib is used to produce gzip streams for HTTP upload request bodies sent
by crashpad_handler by default. The Content-Encoding: gzip header is set
for these compressed request bodies. Compression can be disabled for
upload to servers without corresponding decompression support by
starting crashpad_handler with the --no-upload-gzip option.

Most minidumps compress quite well with zlib. A size reduction of 90% is
not uncommon.

BUG=crashpad:157
TEST=crashpad_util_test GzipHTTPBodyStream.*:HTTPTransport.*

Change-Id: I99b86db3952c3685cd78f5dc858a60b54399c513
Reviewed-on: https://chromium-review.googlesource.com/438585
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-16 16:26:19 +00:00
Erik Chen
c1b305244a Update mig.py to take an explicit sdk argument.
BUG=chromium:690734

> Review-Url: https://codereview.chromium.org/2685233002
> Cr-Commit-Position: refs/heads/master@{#449550}
> Message-Id: Merged from chromium 53f2146935506b4f382705b605dffec41b5519eb

Change-Id: I1b3176a4a62078f1e27184ad589c9c3f4b548674
Reviewed-on: https://chromium-review.googlesource.com/440847
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-10 18:14:10 +00:00
Mark Mentovai
1f82c6cc8a Ensure Content-Length does not appear with Transfer-Encoding
In the HTTPTransport test, verify the requirement of RFC 7230 §3.3.2
that Content-Length not appear if Transfer-Encoding is present.

TEST=crashpad_util_test HTTPTransport.*
BUG=crashpad:159

Change-Id: I51eafff9659443e1d9bb67d1213c8cecc757ded6
Reviewed-on: https://chromium-review.googlesource.com/439984
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-09 17:43:04 +00:00
Mark Mentovai
cd28471383 win: Implement Transfer-Encoding: chunked for HTTP requests
Chunked encoding doesn’t require the length of the request body to be
known in advance. In cases where this value isn’t independently known,
as is normal for Crashpad report uploads where the HTTP request body is
constructed on the fly, chunked encoding eliminates the need to prepare
the entire request body in memory before transmitting it. In these
cases, it’s much less wasteful.

When the length of the request body is known in advance, based on the
provision of a Content-Length header, chunked encoding is not used.
Even so, the request is sent in pieces rather than reading the entire
request into memory before sending anything.

BUG=crashpad:159
TEST=crashpad_util_test HTTPTransport.*

Change-Id: Iebb2b63b936065cb8c3c4a62b58f9c14fec43937
Reviewed-on: https://chromium-review.googlesource.com/439644
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-08 21:17:05 +00:00
Sigurdur Asgeirsson
6af23a933a Use best-effort allocation in ProcessInfo::BuildHandleVector.
BUG=crashpad:158

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

4f3cfc8e7c2b Remove stl_util from mini_chromium

BUG=chromium:555865

Change-Id: I8ecb1639a258dd233d524834ed205a4fcc641bac
Reviewed-on: https://chromium-review.googlesource.com/438865
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-02-07 21:04:42 +00:00
Scott Graham
7050c55fca Remove LazyInstance usage
R=mark@chromium.org
BUG=chromium:686866

Change-Id: I067988694f15d93b064d0b10b1bc5b908c9e5f52
Reviewed-on: https://chromium-review.googlesource.com/435441
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-01-31 22:26:33 +00:00
Mark Mentovai
56020daea9 ExceptionTypes test: test “naked” signals
Since it’s possible to receive an EXC_CRASH for any signal that
generates a core by default even if the signal did not originate from a
Mach exception, update the tests to ensure that all such signals can be
unwrapped from an exception properly. This happens when a signal such as
SIGSEGV is sent with kill(), for example.

Change-Id: I1ee32cc6943f21ae349fa6788430d074acff9ed8
Reviewed-on: https://chromium-review.googlesource.com/434717
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-01-30 16:13:53 +00:00
Mark Mentovai
3e5ae2dc87 Update comments in IsExceptionNonfatalResource() given 10.12 source
With reference to 10.12 source, commentary regarding RESOURCE_TYPE_IO
can be authoritative.

Cursory examination of 10.12 source reveals that RESOURCE_TYPE_MEMORY
can now be fatal, although deeper examination reveals that this is
impossible on macOS. State this authoritatively as well.

BUG=crashpad:124

Change-Id: I52124c68fe017015983ab46e54006ba97ecd0142
Reviewed-on: https://chromium-review.googlesource.com/434297
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-01-30 14:39:27 +00:00
Mark Mentovai
1e4be91918 mac: Faster bit testing for EXC_GUARD exception “flavors”
After e7630628e9c9, I thought “isn’t there a standard library function
for that?” There is!

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

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

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

BUG=chromium:684051

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

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

Change-Id: I4d7080a03623276f9c1c038d6e7329af70e4a64c
Reviewed-on: https://chromium-review.googlesource.com/421564
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-12-16 20:32:25 +00:00
Scott Graham
32981a3ee9 win: Fix clang warning in SECURITY_DESCRIPTOR construction
c:\src\cr\src\third_party\crashpad\crashpad\util\win\registration_protocol_win.cc(193,23):  error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                      SECURITY_MANDATORY_LABEL_AUTHORITY,
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\src\depot_tools\win_toolchain\vs_files\d5dc33b15d1b2c086f2f6632e2fd15882f80dbd3\win_sdk\Include\10.0.10586.0\um\winnt.h(9068,54):  note: expanded from macro 'SECURITY_MANDATORY_LABEL_AUTHORITY'
                                                     ^~~~~~~~~~~~
1 error generated.

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

Change-Id: I1121a42ca98d8a7432e247d4b44a9ad1214d4b39
Reviewed-on: https://chromium-review.googlesource.com/418010
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-12-08 18:12:04 +00:00
Scott Graham
6b09b08a22 Update util/file/string_file.cc for new base/numerics API
The code was not incorrect before, but this expression is simpler.
Upstream of change made at https://codereview.chromium.org/2528243002.

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

Change-Id: Idae36bd8312666a3254eda02713869776fec0248
Reviewed-on: https://chromium-review.googlesource.com/417981
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-12-07 22:59:35 +00:00
Scott Graham
f94dd14c45 win: fix SECURITY_DESCRIPTOR builder on vs2013
After https://chromium.googlesource.com/crashpad/crashpad/+/5b83e587.

R=mark@chromium.org
BUG=chromium:655788,chromium:656800

Change-Id: Ic33b9daedc340bfce3cc4ddde4eb4c93f68e7ad0
Reviewed-on: https://chromium-review.googlesource.com/417412
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-12-07 21:51:57 +00:00
Scott Graham
5b83e58771 win: Remove use of rpcrt4 and advapi32 from some util code
ConvertStringSecurityDescriptorToSecurityDescriptor() is used when
creating the initial connection pipe. Because this is done from inside
DllMain(), we cannot use advapi32 (where this function is). Instead,
save the binary representation of the self-relative SECURITY_DESCRIPTOR.
It is conceivable that this could change, but unlikely as this is the
same blob that would be stored on a file in NTFS.

Another potential approach would be to not make the pipe available to
all integrity levels here, and instead modify the Chromium sandbox code
to allow a specific pipe name prefix that would have to correspond with
the pipe name that Crashpad creates.

Similarly, UuidCreate() (used when initializing the database) is in a
DLL that can't be loaded early, so use the Linux/Android implementation
on Windows too.

R=mark@chromium.org
BUG=chromium:655788,chromium:656800

Change-Id: I434f8e96fc275fc30d0a31208b025bfc08595ff9
Reviewed-on: https://chromium-review.googlesource.com/417223
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-12-07 20:03:45 +00:00
Mark Mentovai
777634b1eb Use ADDRESS_SANITIZER instead of __has_feature(address_sanitizer)
__has_feature() is a Clang-ism not implemented by GCC.
base/compiler_specific.h provides a HAS_FEATURE() macro that always
returns 0 when __has_feature() is not implemented. Use this macro for
compatibility with GCC and other compilers that do not implement this
Clang extension.

http://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension

For GCC’s Address Sanitizer implementation, test the
__SANITIZE_ADDRESS__ macro that it provides as an alternative to
__has_feature(address_sanitizer).

Note that in Chrome builds, ADDRESS_SANITIZER is pushed in by the build
system. The definition of ADDRESS_SANITIZER provides another way for
that macro to be set. It’s supplementary, not exclusive.

cb33b24372/build/config/BUILD.gn (118)

BUG=crashpad:30

Change-Id: I5c3145d29bbc966925369c03a37b1ecb5622a004
Reviewed-on: https://chromium-review.googlesource.com/413109
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-22 19:28:06 +00:00
Mark Mentovai
5a21fc1573 Fix Windows build after f09d0cde00a1
While building crashpad_database_util.cc:

…\crashpad\tools\crashpad_database_util.cc(150) : error C3861: 'gettimeofday': identifier not found

util/win/time.h has its own GetTimeOfDay() to provide this missing
function on Windows. I don’t know why it’s not in compat. Even so, it
doesn’t return a value, so it’d be unsuitable for use in the PCHECK().
Go back to time() with an errno test.

While building string_number_conversion_test.cc:

…\crashpad\util\stdlib\string_number_conversion_test.cc(242) : error C2220: warning treated as error - no 'object' file generated
…\crashpad\util\stdlib\string_number_conversion_test.cc(242) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
…\crashpad\util\stdlib\string_number_conversion_test.cc(243) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
…\crashpad\util\stdlib\string_number_conversion_test.cc(244) : warning C4146: unary minus operator applied to unsigned type, result still unsigned

Use INT64_C(), and remove a duplicate test case.

Change-Id: I308db9856e492604c7462238cb8b7b66731f0cfe
Reviewed-on: https://chromium-review.googlesource.com/411331
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-15 19:16:48 +00:00
Mark Mentovai
f09d0cde00 Improve time handling and error checking
The database settings object’s last_upload_attempt_time (time_t) field
is switched from uint64_t to int64_t, for better compatibility with
time_t, which is normally a signed type. This change should be
transparent, as there should be no valid high-bit-set 64-bit timestamps
in this field in the wild.

A number of improvements are made to crashpad_database_util’s time
handling. Errors are checked during time conversion.
--set-last-upload-attempt-time=now is a new supported (and documented)
option.

A StringToNumber() overload for int64_t, along with a test, is added to
aid in crashpad_database_util’s time conversions from numeric strings. A
test is also added for the previously-untested uint64_t implementation.

TEST=crashpad_util_test StringNumberConversion.*

Change-Id: I089c4bf7b95f5df0982bdbb3c27b4f6a89db966e
Reviewed-on: https://chromium-review.googlesource.com/410068
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-15 18:53:11 +00:00
Mark Mentovai
b37aa95da7 MSVC++ fix: ALLOW_UNUSED_LOCAL variables only used in static_assert
After f83530bf9a0b and 72fbc56e58d3, while compiling
arraysize_unsafe_test.cc:

…\crashpad\util\misc\arraysize_unsafe_test.cc(58) : error C2220: warning treated as error - no 'object' file generated
…\crashpad\util\misc\arraysize_unsafe_test.cc(58) : warning C4101: 's10' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(33) : warning C4101: 'i1' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(24) : warning C4101: 'c1' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(27) : warning C4101: 'c2' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(55) : warning C4101: 's1' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(39) : warning C4101: 'i4' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(45) : warning C4101: 'l9' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(30) : warning C4101: 'c4' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(42) : warning C4101: 'l8' : unreferenced local variable
…\crashpad\util\misc\arraysize_unsafe_test.cc(36) : warning C4101: 'i2' : unreferenced local variable

The line numbers are totally out of order!

I think that my error was not actually ever running “gclient runhooks”,
so I never tested this locally on Windows as I thought I had.

https://build.chromium.org/p/client.crashpad/builders/crashpad_win_x64_dbg/builds/266/steps/compile%20with%20ninja/logs/stdio

TBR=scottmg@chromium.org (holiday)

Change-Id: I00414b54c04b5b7e3aa564b0c6fd49d20a47b6ea
Reviewed-on: https://chromium-review.googlesource.com/410129
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-11 18:07:16 +00:00
Mark Mentovai
72fbc56e58 MSVC++ fix: Don’t declare local[0] arrays for ARRAYSIZE_UNSAFE test
After f83530bf9a0b, while compiling arraysize_unsafe_test.cc:

…\crashpad\util\misc\arraysize_unsafe_test.cc(24) : error C2466: cannot allocate an array of constant size 0
…\crashpad\util\misc\arraysize_unsafe_test.cc(24) : error C2133: 'c0' : unknown size
…\crashpad\util\misc\arraysize_unsafe_test.cc(25) : error C2070: 'char []': illegal sizeof operand
…\crashpad\util\misc\arraysize_unsafe_test.cc(36) : error C2466: cannot allocate an array of constant size 0
…\crashpad\util\misc\arraysize_unsafe_test.cc(36) : error C2133: 'i0' : unknown size
…\crashpad\util\misc\arraysize_unsafe_test.cc(37) : error C2070: 'int []': illegal sizeof operand
…\crashpad\util\misc\arraysize_unsafe_test.cc(61) : error C2466: cannot allocate an array of constant size 0
…\crashpad\util\misc\arraysize_unsafe_test.cc(61) : error C2133: 's0' : unknown size
…\crashpad\util\misc\arraysize_unsafe_test.cc(62) : error C2070: 'crashpad::test::`anonymous-namespace'::ArraySizeUnsafe_ArraySizeUnsafe_Test::TestBody::S []': illegal sizeof operand

MSVC++ 2015 (14.0) doesn’t mind, and I thought that testing that version
would be enough, but the Crashpad buildbots still run MSVC++ 2013
(12.0), which doesn’t like this construct.

https://build.chromium.org/p/client.crashpad/builders/crashpad_win_x64_dbg/builds/265/steps/compile%20with%20ninja/logs/stdio

TBR=scottmg@chromium.org (holiday)

Change-Id: Ia8d140ceda3cd1bdec09c78560377b9bfad84dc4
Reviewed-on: https://chromium-review.googlesource.com/410128
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-11 17:54:08 +00:00
Mark Mentovai
f83530bf9a GCC fix: Don’t use arraysize() on packed structs
While compiling, for example, minidump_exception_writer.cc:

In file included from ../../minidump/minidump_exception_writer.h:26:0,
                 from ../../minidump/minidump_exception_writer.cc:15:
../../minidump/minidump_exception_writer.cc: In member function ‘void crashpad::MinidumpExceptionWriter::SetExceptionInformation(const std::vector<long unsigned int>&)’:
../../minidump/minidump_exception_writer.cc:67:44: error: cannot bind packed field ‘((crashpad::MinidumpExceptionWriter*)this)->crashpad::MinidumpExceptionWriter::exception_.MINIDUMP_EXCEPTION_STREAM::ExceptionRecord.MINIDUMP_EXCEPTION::ExceptionInformation’ to ‘long unsigned int (&)[15]’
       arraysize(exception_.ExceptionRecord.ExceptionInformation);
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
../../third_party/mini_chromium/mini_chromium/base/macros.h:41:50: note: in definition of macro ‘arraysize’
 #define arraysize(array) (sizeof(ArraySizeHelper(array)))

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

BUG=crashpad:30

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

While compiling, for example, minidump_rva_list_writer.cc:

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

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

BUG=crashpad:30

Change-Id: Iec6b1557441b69d75246f2f75c59c4158fb7ca29
Reviewed-on: https://chromium-review.googlesource.com/409641
Reviewed-by: Scott Graham <scottmg@chromium.org>
2016-11-11 17:37:14 +00:00
Mark Mentovai
741c9cc51e mac: Deal with bootstrap_look_up() race encountered on 10.12.1
bootstrap_look_up() “successfully” returns MACH_PORT_DEAD about half of
the time on 10.12.1 16B2657 (xnu-3789.21.4). Replace that with
MACH_PORT_NULL in the BootstrapLookUp() wrapper that all callers are
already routed through.

BUG=crashpad:139
TEST=crashpad_util_test MachExtensions.BootstrapCheckInAndLookUp

Change-Id: I9a39b709add5ca7e64bb5b970ed6ba3fdfd1d47a
Reviewed-on: https://chromium-review.googlesource.com/409671
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-09 22:06:23 +00:00
Mark Mentovai
acabe35928 doc: Fix all Doxygen warnings, cleaning up some generated documentation
This makes Doxygen’s output more actionable by setting QUIET = YES to
suppress verbose progress spew, and WARN_IF_UNDOCUMENTED = NO to prevent
warnings for undocumented classes and members from being generated. The
latter is too noisy, producing 721 warnings in the current codebase.

The remaining warnings produced by Doxygen were useful and actionable.
They fell into two categories: abuses of Doxygen’s markup syntax, and
missing (or misspelled) parameter documentation. In a small number of
cases, pass-through parameters had intentionally been left undocumented.
In these cases, they are now given blank \param descriptions. This is
not optimal, but there doesn’t appear to be any other way to tell
Doxygen to allow a single parameter to be undocumented.

Some tricky Doxygen errors were resolved by asking it to not enter
directiores that we do not provide documentation in (such as the
“on-platform” compat directories, compat/mac and compat/win, as well as
compat/non_cxx11_lib) while allowing it to enter the
“off-platform” directories that we do document (compat/non_mac and
compat/non_win).

A Doxygen run (doc/support/generate_doxygen.sh) now produces no output
at all. It would produce warnings if any were triggered.

Not directly related, but still relevant to documentation,
doc/support/generate.sh is updated to remove temporary removals of
now-extinct files and directories. doc/appengine/README is updated so
that a consistent path to “goapp” is used throughout the file.

Change-Id: I300730c04de4d3340551ea3086ca70cc5ff862d1
Reviewed-on: https://chromium-review.googlesource.com/408812
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 19:24:05 +00:00
Mark Mentovai
952f787f4a doc: Standardize on “macOS” in comments
Use “macOS” as the generic unversioned name of the operating system in
comments. For version-specific references, use Mac OS X through 10.6, OS
X from 10.7 through 10.11, and macOS for 10.12.

Change-Id: I1ebee64fbf79200bc799d4a351725dd73257b54d
Reviewed-on: https://chromium-review.googlesource.com/408269
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 19:21:44 +00:00
Scott Graham
c4cdec3d72 Handle non-crashing cases for server failure to start
Follow up #4!

R=mark@chromium.org
BUG=chromium:567850,chromium:656800
TEST=tests added to crashpad_client_test

Change-Id: I2a53f2168988e620ce240750c6c2d544ba95c8b4
Reviewed-on: https://chromium-review.googlesource.com/406741
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-03 16:38:22 +00:00
Scott Graham
76ef9b5c2b win: Address failure-to-start-handler case for async startup
Second follow up to https://chromium-review.googlesource.com/c/400015/

The ideal would be that if we fail to start the handler, then we don't
end up passing through our unhandled exception filter at all.

In the case of the non-initial client (i.e. renderers) we can do this by
not setting our UnhandledExceptionFilter until after we know we've
connected successfully (because those connections are synchronous from
its point of view). We also change WaitForNamedPipe in the connection
message to block forever, so as long as the precreated pipe exists,
they'll wait to connect. After the initial client has passed the server
side of that pipe to the handler, the handler has the only handle to it.
So, if the handler has disappeared for whatever reason, pipe-connecting
clients will fail with FILE_NOT_FOUND, and will not stick around in the
connection loop. This means non-initial clients do not need additional
logic to avoid getting stuck in our UnhandledExceptionFilter.

For the initial client, it would be ideal to avoid passing through our
UEF too, but none of the 3 options are great:
1. Block until we find out if we started, and then install the filter.
   We don't want to do that, because we don't want to wait.
2. Restore the old filter if it turns out we failed to start. We can't
   do that because Chrome disables ::SetUnhandledExceptionFilter()
   immediately after StartHandler/SetHandlerIPCPipe returns.
3. Don't install our filter until we've successfully started. We don't
   want to do that because we'd miss early crashes, negating the benefit
   of deferred startup.

So, we do need to pass through our UnhandledExceptionFilter. I don't
want more Win32 API calls during the vulnerable filter function. So, at
any point during async startup where there's a failure, set a global
atomic that allows the filter function to abort without trying to signal
a handler that's known to not exist.

One further improvement we might want to look at is unexpected
termination of the handler (as opposed to a failure to start) which
would still result in a useless Sleep(60s). This isn't new behaviour,
but now we have a clear thing to do if we detect the handler is gone.

(Also a missing DWORD/size_t cast for the _x64 bots.)

R=mark@chromium.org
BUG=chromium:567850,chromium:656800

Change-Id: I5be831ca39bd8b2e5c962b9647c8bd469e2be878
Reviewed-on: https://chromium-review.googlesource.com/400985
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-02 21:39:52 +00:00
Mark Mentovai
88e3b6b022 Omit platform-specific assembler source from builds as needed
The default filename rules do not match .S or .asm, so the
platform-specific assembler implementations of CaptureContext() were not
being affirmatively excluded from other platforms’ builds. This
previously worked without causing problems because the Mac build
environment didn’t know what to do with .asm files, and the Windows
build environment didn’t know what to do with .S files. Now that another
platform that may understand .S files is being added, the rules for when
to build these files must be tailored a bit more tightly.

BUG=crashpad:30

Change-Id: Ib62e619c007320d45279c104b3e229d92698aa72
Reviewed-on: https://chromium-review.googlesource.com/406348
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-01 21:17:02 +00:00
Mark Mentovai
fd751f4708 Correct StringToUnsignedInt[64]()
StringToUnsignedInt[64]Traits::Convert() was returning in its failure
(negative input) case without touching *end. Its caller relies on *end
to detect failure.

Change-Id: I636f95471cd499434743e73f0e5e0b60c0871795
Reviewed-on: https://chromium-review.googlesource.com/405468
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-01 15:57:36 +00:00
Mark Mentovai
b978b03fa1 Port most of crashpad_util_test to Linux/Android
- In the ProcessInfo test, port the global argc/argv getter to Linux by
   reading /proc/self/cmdline.
 - Use <inttypes.h> format macros for 64-bit types.
 - Only #include <sys/sysctl.h> on macOS.
 - #include <signal.h> instead of <sys/signal.h>.

In order to test on Linux/Android, the following changes to the
crashpad_util_test target must be made until more porting is complete:

 - Remove the dependency on crashpad_client because that library has not
   been ported yet.
 - Remove process_info_test.cc because it depends on crashpad_client and
   there is no implementation of ProcessInfo for Linux yet.
 - Remove http_transport_test.cc because there is no HTTPTransport
   implementation for Linux or Android yet.
 - Remove checked_address_range_test.cc because checked_address_range.cc
   does not yet expose a cross-bit usable type for addresses and sizes
   on Linux.

BUG=crashpad:30
TEST=crashpad_util_test

Change-Id: Ic17cf26bdf19b3eff3915bb1acdaa701f28222cd
Reviewed-on: https://chromium-review.googlesource.com/405647
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-10-31 21:07:06 +00:00
Mark Mentovai
e956a8252f Port the util library to Android
With this change, it is possible to build crashpad_util for Android with
clang. I built with NDK 13b (clang 3.8) at API 24 (current), API 21
(used by Chrome in 64-bit builds), and API 16 (used by Chrome in 32-bit
builds).

 - In WeakFileHandleFileWriter::WriteIoVec(): Android does not expose
   the IOV_MAX macro, but its value can be obtained by calling
   sysconf(_SC_IOV_MAX).
 - In CloseMultipleNowOrOnExec(): API 21 removes getdtablesize(). Skip
   it, because it returned the same thing as sysconf(_SC_OPEN_MAX),
   which is already consulted.
 - Throughout: Various #ifdefs checking for OS_LINUX have been extended
   to also check for OS_ANDROID. In Chrome’s build_config.h (and thus
   mini_chromium’s), OS_LINUX is not defined when OS_ANDROID is.

This has not been tested beyond building the crashpad_util target.

BUG=crashpad:30

Change-Id: Ieb0bed736029d2d776c534e30e534f186e6fb663
Reviewed-on: https://chromium-review.googlesource.com/405267
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-10-31 15:23:43 +00:00
Mark Mentovai
f735d050c4 Port the util library to Linux
With this change, it is possible to build crashpad_util on Linux. I
built with clang 3.8.1 and GCC 6.2.0.

 - For per-OS “exception code” metrics, Android and Linux are broken out
   distinctly.
 - Because Linux provides no standard UUID generator, base::RandBytes()
   is used to generate random UUIDs for the InitializeWithNew() form.
 - Multiple fixes for CloseMultipleNowOrOnExec():
    - readdir_r() is deprecated in glibc 2.24. Use readdir() on Linux.
    - Linux does not have OPEN_MAX. Use the fs.nr_open sysctl (via
      /proc/sys) to determine the maximum (currently-configured)
      possible number of file descriptors per process.
    - Use the {CTL_KERN, KERN_MAXFILESPERPROC} sysctl on Mac to
      determine the maximum (currently-configured) possible number of
      file descriptors per process. This is an improvement over using
      OPEN_MAX, which is still consulted.
 - ThreadLogMessages’ use of DCHECK_EQ() needs an address-of operator on
   function pointers to avoid confusing GCC.

One problem remains:

 - util/misc/pdb_structures.h produces -Wmultichar errors. -Wmultichar
   is enabled by default with GCC (but not clang). It is impossible to
   disable this warning with #pragma GCC diagnostic ignored. See
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431

This has not been tested beyond building the crashpad_util target.

BUG=crashpad:30

Change-Id: I02e7a05da512ca312806d825b3fc9b2c5bf1a990
Reviewed-on: https://chromium-review.googlesource.com/404009
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-10-31 15:20:59 +00:00
Scott Graham
cc0b7deef2 Get VS2013 compilation working again for Crashpad
Follow up #1 to https://chromium-review.googlesource.com/c/400015/,
still pending further discussion on details of registration.

R=mark@chromium.org
BUG=chromium:567850,chromium:656800

Change-Id: Idfee3a3241d7cfe418fbf9e40f17f35e5dbefac9
Reviewed-on: https://chromium-review.googlesource.com/401182
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-22 00:05:02 +00:00
Scott Graham
2d87606bb5 win: Start crashpad_handler by inheriting connection data to it
Previously, StartHandler() launched the handler process, then connected
over a pipe to register for crash handling. Instead, the initial client
can create and inherit handles to the handler and pass those handle
values and other data (addresses, etc.) on the command line.

This should improve startup time as there's no need to synchronize with
the process at startup, and allows avoiding a call to CreateProcess()
directly in StartHandler(), which is important for registration for
crash reporting from DllMain().

Incidentally adds new utility functions for string/number conversion and
string splitting.

Note: API change; UseHandler() is removed for all platforms.

BUG=chromium:567850,chromium:656800

Change-Id: I1602724183cb107f805f109674c53e95841b24fd
Reviewed-on: https://chromium-review.googlesource.com/400015
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-21 20:35:58 +00:00
Erik Chen
1e6dbcb300 Support passing DEVELOPER_DIR to mig.py
BUG=chromium:651267

Change-Id: If02f9bac603237677d348869d05d7b4d0b31909e
Reviewed-on: https://chromium-review.googlesource.com/392486
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-04 14:50:45 +00:00
Scott Graham
a16a7fd4ef win: Make DumpAndCrash() always terminate, and tidy up special codes
Upstreaming with tidying up of
https://codereview.chromium.org/2377693002/.

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

Change-Id: Ie8b3b673c8d2a06c5cc918a034688aa9396cfbf4
Reviewed-on: https://chromium-review.googlesource.com/390436
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-29 04:44:20 +00:00
Scott Graham
5a6c961658 Add metric for handler crash on Windows
R=mark@chromium.org
BUG=crashpad:100

Change-Id: I80de83d133cd9968af17e50798d6a5c6bd121b4b
Reviewed-on: https://chromium-review.googlesource.com/390480
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-28 20:43:24 +00:00
Scott Graham
ac6c01b575 Add metrics for tracking uploads
Three new metrics:
- counting upload success/failure;
- enum tracking the reason upload was skipped;
- enum describing how an upload got to the pending state.

R=mark@chromium.org, asvitkine@chromium.org
BUG=crashpad:100

Change-Id: I5e0cbc1ac3424e974f3a51560e5cdad484ffc038
Reviewed-on: https://chromium-review.googlesource.com/388855
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-26 22:09:32 +00:00
Scott Graham
0aeca5f123 UMA changes based on Chromium-side review
Per comments in https://codereview.chromium.org/2350943003/:
- Increase the upper bound for Crashpad.CrashReportSize to 20M
- Make ExceptionEncountered a 2 enum bucket to track start/end.

R=asvitkine@chromium.org, mark@chromium.org
BUG=crashpad:100

Change-Id: Ie848b2e3744c58f6d669986d3e78e7391b0e9e68
Reviewed-on: https://chromium-review.googlesource.com/387685
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-21 18:05:14 +00:00
Scott Graham
007f790fe2 static const on const char[] for UMA string
By request on https://codereview.chromium.org/2350943003.

BUG=crashpad:100

Change-Id: I64292793dd51e72d102d90506181ae0fc7ef1c63
Reviewed-on: https://chromium-review.googlesource.com/387195
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-20 21:49:50 +00:00
Scott Graham
17167a1e57 static_cast UMA 'enum class's to int
Otherwise, the Chromium expansions complain about not being able to add
and needing explicit conversions.

R=mark@chromium.org
BUG=crashpad:100

Change-Id: I0540a8dabff61f2189d9532422adae5c2885ae03
Reviewed-on: https://chromium-review.googlesource.com/387166
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-20 00:24:54 +00:00
Scott Graham
72a12e2e94 Make UMA for exception code OS-specific
R=wfh@chromium.org, mark@chromium.org
BUG=crashpad:100

Change-Id: I9368168405d1bd761ae6205955968264543541c4
Reviewed-on: https://chromium-review.googlesource.com/386989
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-19 21:57:18 +00:00
Scott Graham
b48e9bfbab Add UMA to exception handler exception catching
Includes mini_chromium DEPS roll for:
88e0a3e Add stub of sparse_histogram.h

R=mark@chromium.org
BUG=crashpad:100

Change-Id: I4c541a33be0f7f47e972af638d4765bd06682acf
Reviewed-on: https://chromium-review.googlesource.com/386385
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-19 18:10:31 +00:00
Scott Graham
afc177ee21 Pull metrics instrumentation out to central file
Solves two problems with having the macros inline:

1. Deduplicates some of the logic (in this case, the name of the
   histogram, and whether it should be divided by 1024);

2. More useful check for compilation. As the macros are no-ops in
   Crashpad, it was easy to use the wrong name for a variable in the
   arguments to the macros (see .mm!)

This way, we have some better chance of at least having code that
compiles when built in Chromium if all the arguments are passed to
Metrics::Something() in a standalone build.

Also rolls mini_chromium DEPS to include:
99213eb Mark histogram arguments as unused to avoid warnings

R=mark@chromium.org
BUG=crashpad:100

Change-Id: I9f7fc3b85854fd61c1ebdf0084d728a7b690c2f1
Reviewed-on: https://chromium-review.googlesource.com/380445
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-02 19:13:00 +00:00
Scott Graham
5f42313ed5 Test first integration of UMA plumbing
Add a first example of a UMA entry to have it available to try to plumb
through to Chromium.

Adds LoggingFileSizeByHandle() to util/file/file_io.* to retrieve the
size of on disk file to report to UMA.

Also rolls DEPS for mini_chromium to include:
b5ec9ce Add stub versions of histogram_macros.h

R=mark@chromium.org
BUG=crashpad:100

Change-Id: Ib8e96ad4b7d715b46d2c71810c95c92965a89821
Reviewed-on: https://chromium-review.googlesource.com/338821
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-02 00:04:29 +00:00
Gayane Petrosyan
b35ee1fca1 Adding support for on-demand uploads.
In order to allow on-demand uploads for crash reports, adding a
upload_explicitly_requested bit on 'pending' state and necessary support
for it.

BUG=chromium:620762

Change-Id: Ida38e483fe8d0e48eb5cbe95e8b8bfd96a2f8f00
Reviewed-on: https://chromium-review.googlesource.com/367328
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-08-24 21:57:02 +00:00