90 Commits

Author SHA1 Message Date
Peter Boström
6265674c98 Migrate to NOTREACHED()
This was tested locally by adding "-Wunreachable-code-aggressive" after
making NOTREACHED() [[noreturn]] in mini_chromium and then getting that
to compile.

Bug: chromium:40580068
Change-Id: I7ec1c72be1d73436d128660a621e9060eaebaee8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5780891
Reviewed-by: Mark Mentovai <mark@chromium.org>
2024-08-14 03:11:45 +00:00
Peter Boström
6af42bc0b2 Use NOTREACHED_IN_MIGRATION()
This was generated by replacing "  NOTREACHED()" with
"  NOTREACHED_IN_MIGRATION()" and running git cl format.

This prepares for making NOTREACHED() [[noreturn]] alongside
NotReachedIsFatal migration of existing inventory.

Bug: chromium:40580068
Change-Id: Idb68e2fc8adba180350b0595fd494cf0f206bded
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5548246
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
2024-05-17 16:30:52 +00:00
Lei Zhang
1675ce7c58 Add missing base/check.h includes
Do not rely on base/logging.h to provide it.

Change-Id: I8b7d733bcf66abe9b46eabd3703b7ed549d02db7
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5007844
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2023-11-06 22:00:17 +00:00
Eric Astor
59fc31ce00 Update mini_chromium & use its new support for wide streaming in file_path
Fixes a pending issue when we eventually move to C++20.

Original author: Dean Sturtevant

Change-Id: I7bb0648c73df6b6a28a3a4debdb4524d3cd27b38
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4979733
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Eric Astor <epastor@google.com>
2023-10-26 22:15:17 +00:00
Alex Gough
a5e179663a Catch heap corruption failures on Windows
Windows claims that heap corruption crashes are passed
to Windows Error Reporting but they are not, they are
swallowed and the process is simply terminated. WerFault.exe
does not run.

We can however intercept these crashes using a vectored
exception handler which forwards STATUS_HEAP_CORRUPTION
to the normal crash handler.

Adds an end-to-end test.

Bug: 2515
Change-Id: I2e1361dacef6fd03ea0f00327fee0b05a0c4899e
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4637533
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2023-06-23 23:06:52 +00:00
Alex Gough
bc1e904f09 SetErrorMode() in fastfail tests
Some versions of python call SetErrorMode which disables
WerFault handling for the fastfail test programs. We can
set this to a useful value, allowing these tests to run
again locally.

This does not enable the tests on the bots as they continue
to fail.

Bug: crashpad:458
Change-Id: Ibdd2f92ed872bd76490db32dccb2257dd91f8280
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4641231
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2023-06-23 20:49:06 +00:00
Vaibhav Nagarnaik
9158eb7caa handle num_handled_exceptions == 0 case
from documentation of `ProcessException` in `crashpad_wer.h`:

```
//! \param[in] handled_exceptions is an array of exception codes that the helper
//!     should pass on to crashpad handler (if possible). Pass nullptr and set
//!     num_handled_exceptions to 0 to pass every exception on to the crashpad
//!     handler.
```

fix the check to handle `num_handled_exceptions == 0` case to not filter
out any exceptions.

Bug: crashpad:439
Change-Id: Ic4559a730a26e37c7a8f13e6bcae7595d743924a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4206503
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
2023-01-31 04:56:47 +00:00
Alan Zhao
cca548be84 Minor fixes for crashpad_wer_main.cc
These were suggested after https://crrev.com/c/3864248 was submitted.

Change-Id: I73c451a3ea52721d8476e229cff7a0aded6746ac
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3902210
Commit-Queue: Alan Zhao <ayzhao@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-09-19 21:01:38 +00:00
Alex Gough
ca928c8d6b Work around pre 19041 SDK definition
SDK definition of WER_RUNTIME_EXCEPTION_INFORMATION changed in SDK 19041
to add the bIsFatal field which we use. This adds a local definition of
the newer structure to allow the WER handler to build on earlier SDKs.

Bug: crashpad:423
Change-Id: I23bb69cc002ac8d469227e549f29b0af4849c893
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3880663
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2022-09-19 17:52:23 +00:00
Alan Zhao
02399418fc Fix comment in crashpad_wer.h
Empty arrays aren't allowed in C/C++, so we advise callers to pass
nullptr instead.

Change-Id: If6724fa5a8b657207337df8b36fa2b3b4fddd955
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3894498
Reviewed-by: Ben Hamilton <benhamilton@google.com>
Commit-Queue: Alan Zhao <ayzhao@google.com>
2022-09-13 21:46:33 +00:00
Mark Mentovai
6278690abe Update copyright boilerplate, 2022 edition (Crashpad)
sed -i '' -E -e 's/Copyright (.+) The Crashpad Authors\. All rights reserved\.$/Copyright \1 The Crashpad Authors/' $(git grep -El 'Copyright (.+) The Crashpad Authors\. All rights reserved\.$')

Bug: chromium:1098010
Change-Id: I8d6138469ddbe3d281a5d83f64cf918ec2491611
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3878262
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-09-06 23:54:07 +00:00
Alan Zhao
261679b3d2 Move registration_protocol_win structs to their own header file
registration_protocol_win.h includes <string>, which adds an
unacceptable dependency on libc++ in //components/crash/win:chrome_wer
in Chrome as that file is included in crashpad_wer.cc. Rather than
remove <string>, which would require doing a lot of transitive
refactoring work in Crashpad, we just extract the data structures into
another file, as crashpad_wer.cc only includes
registration_protocol_win.h for its struct definitions.

Bug: chromium:1357827
Change-Id: Ic20c2952be07ea75d063702cd346cdca0ab65038
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3864251
Commit-Queue: Alan Zhao <ayzhao@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-08-31 18:06:58 +00:00
Alan Zhao
54da37c2d2 Remove std::vector from crashpad_wer
When assertions were enabled in Chrome in https://crrev.com/c/3833545,
crashpad_wer now requires libc++ to be explicitly included if compiled
with -std=c++20 because <vector> would now reference symbols defined
outside the libc++ headers. We attempted to add libc++ as a dependency
in https://crrev.com/c/3862974; however, that was deemed unacceptable
because the library needs to be kept small in order for Windows to load
it to handle crashes. Therefore, the only alternative is to update the
library to remove std::vector

Bug: chromium:1357827
Change-Id: I1494204a7bd679fa1632a0f08597cb7e93267196
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3864248
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alan Zhao <ayzhao@google.com>
2022-08-30 20:51:37 +00:00
Alex Gough
80520bd937 Add WER runtime exception helper module for Windows
This adds a runtime exception helper (& test module) for Windows and
plumbing to allow the module to be registered by the crashpad client,
and to trigger the crashpad handler. Embedders can build their own
module to control which exceptions are passed to the handler.

See: go/chrome-windows-runtime-exception-helper for motivation.

When registered (which is the responsibility of the embedding
application), the helper is loaded by WerFault.exe when Windows
Error Reporting receives crashes that are not caught by crashpad's
normal handlers - for instance a control-flow violation when a
module is compiled with /guard:cf.

Registration:

The embedder must arrange for the full path to the helper to
be added in the appropriate Windows Error Reporting\
RuntimeExceptionHelperModules registry key.

Once an embedder's crashpad client is connected to a crashpad
handler (e.g. through SetIpcPipeName()) the embedder calls
RegisterWerModule. Internally, this registration includes handles
used to trigger the crashpad handler, an area reserved to hold an
exception and context, and structures needed by the crashpad handler.

Following a crash:

WerFault.exe handles the crash then validates and loads the helper
module. WER hands the helper module a handle to the crashing target
process and copies of the exception and context for the faulting thread.

The helper then copies out the client's registration data and
duplicates handles to the crashpad handler, then fills back the various structures in the paused client that the crashpad handler will need.

The helper then signals the crashpad handler, which collects a dump then
notifies the helper that it is done.

Support:

WerRegisterExceptionHelperModule has been availble since at least
Windows 7 but WerFault would not pass on the exceptions that crashpad
could not already handle. This changed in Windows 10 20H1 (19041),
which supports HKCU and HKLM registrations, and passes in more types of
crashes. It is harmless to register the module for earlier versions
of Windows as it simply won't be loaded by WerFault.exe.

Tests:

snapshot/win/end_to_end_test.py has been refactored slightly to
group crash generation and output validation in main() by breaking
up RunTests into smaller functions.

As the module works by being loaded in WerFault.exe it is tested
in end_to_end_test.py.

Bug: crashpad:133, 866033, 865632
Change-Id: Id668bd15a510a24c79753e1bb03e9456f41a9780
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3677284
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2022-07-07 17:13:24 +00:00
Daniel Cheng
0affe61689 Migrate base::{size,empty,data} to STL equivalents in crashpad.
Bug: chromium:1299695
Change-Id: I95187a425b08c96430c659f843c379d506972f0f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3496462
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-03-01 12:06:49 +00:00
Ben Hamilton
e9937cb36c [Cleanup] Fix circular dependency on Windows.
Crashpad currently has a circular dependency: client->snapshot->client.

The dependency from snapshot -> client only exists to pull in a single
constant for Windows (CrashpadClient::kTriggeredExceptionCode), so this
change breaks the dependency by splitting the constant out into a new
file util/win/exception_codes.h.

Change-Id: I6b74b367df716e097758e63a44c53cb92ea5e04d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3450763
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-02-17 19:33:24 +00:00
Justin Cohen
bc138fc01c Initialize process snapshot client ids to zero.
Change-Id: If6e1902d62e6364114a75d8ebc4d260e4239d58b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3296266
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-23 20:59:19 +00:00
Peter Boström
1aa478d161 Remove DISALLOW_* macros in crashpad
This change was partially scripted and partially done manually with vim
regex + manually placing the deleted constructors.

The script change looked for destructors in the public: section of a
class, if that existed the deleted constructors would go before the
destructor.

For manual placement I looked for any constructor in the public: section
of the corresponding class. If there wasn't one, then it would ideally
have gone as the first entry except below enums, classes and typedefs.
This may not have been perfect, but is hopefully good enough. Fingers
crossed.

#include "base/macros.h" is removed from files that don't use
ignore_result, which is the only other thing defined in base/macros.h.

Bug: chromium:1010217
Change-Id: I099526255a40b1ac1264904b4ece2f3f503c9418
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3171034
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
2021-09-21 15:09:44 +00:00
Peter Kasting
a7177e8bec Fix -Wunreachable-code-aggressive.
Bug: 1066980
Change-Id: Idf51fbf5fc45a33aef4830d76d324011871e2b6a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2997563
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
2021-06-30 17:55:56 +00:00
Justin Cohen
ce378c4293 Fix some chromium roll errors and warnings.
Remove unneeded base/strings/stringprintf.h includes.
ARCH_CPU_X86_64 macro is used without including build/build_config.h
Missing base/check.h

Change-Id: Ib7864ab7b30ef8fc37649783f7b90b618d0d6a0b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2920552
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2021-06-02 22:02:42 +00:00
Lei Zhang
d8f60c8112 Swap from base/stl_util.h to cxx17_backports.h.
Chromium moved base::size() to base/cxx17_backports.h, so do the same in
mini_chromium and update the users in Crashpad.

Roll mini_chromium to 2f06f83f to make the new base header available.

Bug: chromium:1210983
Change-Id: Ie3dc4c189dcdfcac030b95fe285f94abb29a27bf
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2917779
Commit-Queue: Lei Zhang <thestig@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-05-25 21:44:52 +00:00
Jan Wilken Dörrie
8cdc852a9e Prepare hanging_program for string16 switch
Bug: chromium:911896
Change-Id: I39d4356be8ba0c0fd8a4840d24b9eb0e83acc42d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2719888
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-02-25 14:29:07 +00:00
Jan Wilken Dörrie
a98ee20e57 [crashpad] Prepare crashpad for base::string16 switch
This change prepares crashpad for the upcoming switch of base::string16
to std::u16string on all platforms. It does so by replacing Windows-only
instances of base::string16 with std::wstring, and using appropriate
string utility functions.

Bug: chromium:911896
Change-Id: Ibb0b8a4e4dc7fae1d24d18823f8dbb6da31f8239
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2332402
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-12 07:36:53 +00:00
IrinaShkviro
4145699874 win,linux: implement attachments support
Implemented the AddAttachment(), InitializeAttachments(), CleanDatabase() functions
on Windows.

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

Bug: b/157144387

Change-Id: Ia238de39028e07112a7b971b5b7d5e71a5864f53
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2248099
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2020-06-24 16:19:27 +00:00
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
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
Joshua Peraza
cd92fba233 linux: Move Cros crash handling to CrosCrashReportExceptionHandler
Change-Id: I80686ddc35b03fa213481e35dc494a40fbdd551a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1775222
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2019-08-30 19:49:26 +00:00
Tom Tan
84ef87ef51 Fix arm64 CONTEXT for crashy_test_program
Bug: chromium:893460
Change-Id: I0bd47521d68aa9477e32104986bd7aeb1d4e2738
Reviewed-on: https://chromium-review.googlesource.com/c/1454820
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2019-02-05 20:06:48 +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
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
Joshua Peraza
c80bf96001 Don't record reports as complete if there is no upload thread
This allows clients to use the database to handle uploads themselves,
e.g. on Android, where Crashpad does not yet provide an uploader.

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

Bug: crashpad:30
Change-Id: I4167ab1531634b10e91d03229018ae6aab4103aa
Reviewed-on: https://chromium-review.googlesource.com/1010970
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-04-13 16:20:01 +00:00
Joshua Peraza
07da37aec7 win: fix crashy test program
end_to_end_test.py expects g_extra_memory_pointer data to be 32-bit,
so use a fixed-size type.

Change-Id: I5798bc8a895d7e02461671fd31e59dd178f6a6a4
Reviewed-on: https://chromium-review.googlesource.com/957792
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-03-12 20:46:44 +00:00
Joshua Peraza
4375233ad2 win: fix 64-bit build
The 64-bit win build broke in
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/944192
but it was missed because we're missing 64-bit win buildbot coverage.

Change-Id: Ic3c40006c15bb85408bc869a0b595a652b9ac14e
Reviewed-on: https://chromium-review.googlesource.com/947716
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-03-03 03:56:39 +00:00
Joshua Peraza
82777cff58 win: fix warnings when building with clang
Change-Id: I15eeeb3d16490054351c1c641acb4159d0a13d89
Reviewed-on: https://chromium-review.googlesource.com/944192
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-03-01 21:53:24 +00:00
Joshua Peraza
493e29bc3d win: Use correct format specifier
This caused an error with clang, but not msvc.
At first I thought this might be a discrepancy between the warning
levels used, but it appears msvc was okay with this because ints are
the same size as longs.

Change-Id: I798284fef9aa70b1bfda73308b9babe1779e8f4b
Reviewed-on: https://chromium-review.googlesource.com/941723
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-02-28 19:54:53 +00:00
Joshua Peraza
ebad8bd925 Don't spawn an upload thread if url is empty
Also automatically stop upload and prune threads on destruction.

Bug: crashpad:30
Change-Id: I45a30944eb3052182da296e00a6d6041691ab772
Reviewed-on: https://chromium-review.googlesource.com/924456
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-20 19:02:29 +00:00
Joshua Peraza
0429216f59 linux: Add CrashReportExceptionHandler
Bug: crashpad:30
Change-Id: I2855b34abe34f6d665539de0e4a227c933bd2b8c
Reviewed-on: https://chromium-review.googlesource.com/922923
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-16 17:17:57 +00:00
Joshua Peraza
c45ba7920e Make NewReport objects own their associated database resources
This change updates CrashReportDatbase::NewReport objects to own the
file handle associated with the new report, now accessible via a
FileWriter. NewReport's destructor closes its file handle and removes
its new report unless disarmed with FinishedWritingCrashReport,
eliminating the need for CallErrorWritingCrashReport.

Bug: crashpad:206
Change-Id: Iccb5bbc0ebadb07a237ff8eb938389afcfeae2a5
Reviewed-on: https://chromium-review.googlesource.com/916941
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-02-14 01:33:52 +00:00
Scott Graham
885fb47a0d Make CrashpadClient::DumpAndCrashTargetProcess static
Noticed during discussion for
https://chromium-review.googlesource.com/c/chromium/src/+/896638 and the
linked bug that there's no need for this to be an instance method. Make
it static as it's easier to use.

Bug: chromium:806661
Change-Id: I24b893e58a47b5256b3b1b43dd5f1fc2d7cc6be8
Reviewed-on: https://chromium-review.googlesource.com/898439
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-02 20:54:44 +00:00
Joshua Peraza
9b2ba587f6 linux: Add ExceptionHandlerServer and ExceptionHandlerClient
Bug: crashpad:30
Change-Id: I60874a26ccb281144f870df2b4d16c6970a39f6b
Reviewed-on: https://chromium-review.googlesource.com/772824
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-19 20:11:52 +00:00
Mark Mentovai
20e5aba1af URL cleanups: switch to HTTPS, fix dead ones, use canonical ones
Change-Id: I4b247d7fae1a212350f8ffcf2bf5ba1fa730f5c1
Reviewed-on: https://chromium-review.googlesource.com/780339
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-11-20 22:23:39 +00:00
Mark Mentovai
1669ca2bac test: Rework TestPaths interface for obtaining 32-bit build artifacts
The design for running all Crashpad unit tests on Chromium’s try- and
buildbots involves pulling all tests into a single monolithic
crashpad_tests executable. Many Crashpad tests base the name of their
child executables or modules on the name of the main test executable.
Since the main test executable will have a different name in the
in-Chromium build, knowledge of the test executable name (referred to as
“module” here) needs to be added to the tests themselves.

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

Bug: chromium:779790
Change-Id: I64c4a2190b6319e487c999812a7cfc512a75a700
Reviewed-on: https://chromium-review.googlesource.com/747536
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-11-01 16:44:45 +00:00
Mark Mentovai
370e441962 win: Address late feedback after 90054edf6202
Bug: crashpad:197
Change-Id: I2b6758d46f3ee9562ce027d321cb6b506dc78269
Reviewed-on: https://chromium-review.googlesource.com/701214
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-10-04 21:22:51 +00:00
Mark Mentovai
90054edf62 win: De-flake hanging_program.exe
hanging_program.exe is used by crash_other_program.exe, which is in turn
used by end_to_end_test.py. It hangs by loading loader_lock_dll.dll,
which squats in its entry point function while the loader lock is held.

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

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

Bug: crashpad:197
Test: end_to_end_test.py
Change-Id: Ib9883215ef96bed7571464cc68e09b6ab6310ae6
Reviewed-on: https://chromium-review.googlesource.com/700076
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-10-04 19:58:56 +00:00
Mark Mentovai
6dac7ecdf5 Use constexpr at function scope
This is essentially based on a search for “^ *const [^*&]*=[^(]*$”

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

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

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

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

Change-Id: I3513b739ee8b0be026f8285475cddc5f9cc81152
Reviewed-on: https://chromium-review.googlesource.com/583997
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-07-25 17:40:51 +00:00
Mark Mentovai
74fddc3fed win: Wrap test::ChildLauncher::Start() in ASSERT_NO_FATAL_FAILURE()
Test: crashpad_snapshot_test, crashpad_util_test, end_to_end_test
Change-Id: I09581521678fe3b083c409f308eeab2e583b3c9f
Reviewed-on: https://chromium-review.googlesource.com/481245
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-19 17:47:23 +00:00
Mark Mentovai
8297b19a5e Don’t attempt to do periodic tasks in a secondary crashpad_handler
76a67a37b1d0 adds crashpad_handler’s --monitor-self argument, which
results in a second crashpad_handler instance running out of the same
database as the initial crashpad_handler instance that it monitors. The
two handlers start at nearly the same time, and will initially be on
precisely the same schedule for periodic tasks such as scanning for new
reports to upload and pruning the database. This is an unnecessary
duplication of effort.

This adds a new --no-periodic-tasks argument to crashpad_handler. When
the first instance of crashpad_handler starts a second to monitor it, it
will use this argument, which prevents the second instance from
performing these tasks.

When --no-periodic-tasks is in effect, crashpad_handler will still be
able to upload crash reports that it knows about by virtue of having
written them itself, but it will not scan the database for other pending
reports to upload.

Bug: crashpad:143
Test: crashpad_util_test ThreadSafeVector.ThreadSafeVector
Change-Id: I7b249dd7b6d5782448d8071855818f986b98ab5a
Reviewed-on: https://chromium-review.googlesource.com/473827
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-04-14 19:52:14 +00:00
Mark Mentovai
5d07d81458 Fix Doxygen warnings after 30385d4e4772
Bug: crashpad:167
Change-Id: Ia12abd5298e4a2a3822d6641ef9d19eb05c41f38
Reviewed-on: https://chromium-review.googlesource.com/477012
Reviewed-by: Sigurður Ásgeirsson <siggi@chromium.org>
2017-04-13 17:52:43 +00:00
Sigurdur Asgeirsson
30385d4e47 handler: Add user extensibility stream call-out.
Bug: crashpad:167
Test: Add crashpad_handler_test.
Change-Id: I79b0b71dc4f61e6dce6bc10083e2f924dc83c940
Reviewed-on: https://chromium-review.googlesource.com/463746
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-04-11 19:06:00 +00:00