29 Commits

Author SHA1 Message Date
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
Justin Cohen
df86075acc ios: Prevent duplicate uploads and watchdog kills with slow uploads.
On iOS, holding a lock during a slow upload can lead to watchdog kills
if the app is suspended mid-upload. Instead, if the client can obtain
the lock, the database sets a lock-time file attribute and releases the
flock. The file attribute is cleared when the upload is completed. The
lock-time attribute can be used to prevent file access from other
processes, or to discard reports that likely were terminated mid-upload.

Bug:chromium:1342051
Change-Id: Ib878f6ade8eae467ee39acb52288296759c84582
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3739019
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-07-14 18:47:58 +00:00
Olivier Robin
c8d8dd9ccf Add attachment support for Mac/iOS crash report database
Copy the crash_report_database_generic implementation.

bug: crashpad: 31
Change-Id: I582620ec8b22fecc7568d220c410c397948dfcb1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3045405
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-11-15 17:41:54 +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
Justin Cohen
1d45a4bafb Pass FilePath by reference in CrashReportDatabase.
Missing &.

Change-Id: I3a5b14cecb6fe6e7c9e44f79b00101b15157a856
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2920553
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2021-06-03 16:10:26 +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
Joshua Peraza
6c0f5ccaa8 Add NewReport::Reader to read back new reports
Change-Id: If53a63aac2b213b02619bb5277e5618c0e7842b3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2019566
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-01-24 18:51:59 +00:00
Francois Rousseau
8e222b90b7 fix report size computation in prune condition
today the attachments are not taken into account, but should on Linux and Fuchsia

Bug: fuchsia:DX-1104

Tested:`fx run-test crashpad_test` for Fuchsia.

Change-Id: I022331bdb09c637f40ff2ba2d711e301e211e86a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1518323
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Francois Rousseau <frousseau@google.com>
2019-03-14 18:00:18 +00:00
Mark Mentovai
39e458b331 Remove (a? the last?) extraneous semicolon
Bug: chromium:926235
Change-Id: Ie30810641c1d0dcc735002443f7a18facd9508a8
Reviewed-on: https://chromium-review.googlesource.com/c/1475993
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
2019-02-21 15:58:50 +00:00
Joshua Peraza
2418cb8fbe Make upload report metrics optional
Bug: crashpad:30
Change-Id: I202e4571ee8dc8006550173c1cf0c735fae29103
Reviewed-on: https://chromium-review.googlesource.com/1148580
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-07-24 17:05:28 +00:00
Scott Graham
1f3052c1cc Add support for attachments to generic crash report database
This is the beginning of support for attachments at the process level
being stored alongside a report. Attachments will be uploaded by key as
part of the multipart http upload. There's no interface at the client
level yet to pass these through.

As this is intended for Fuchsia, this is not yet implemented for the
Mac/Windows database implementations.

Bug: crashpad:196
Change-Id: Ieaf580675164b631d313193f97375710979ba2a9
Reviewed-on: https://chromium-review.googlesource.com/1060419
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-05-18 23:01:16 +00:00
Joshua Peraza
8d0d999d92 Add a cross-platform database implementation
This CL, based on
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/689745
adds a cross-platform database implementation side-by-side with the
existing macOS and Windows implementations. The generic implementation
is used for Linux, Android and Fuchsia.

The database uses the directory structure from the macOS
implementation, but stores report metadata in companion files for each
report, rather than using filesystem attributes. The database uses
lockfiles (companion files opened with O_EXCL) to protect report access
because they are widely supported across filesystems. Lost lockfiles
are removed after 3 days, along with any reports or metadata they were
protecting.

Bug: crashpad:206
Change-Id: I086e9001350e4446dd2f8c12fd3817377f509d3e
Reviewed-on: https://chromium-review.googlesource.com/919527
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-15 19:14:22 +00:00
Joshua Peraza
c406797ce6 Add UploadReport to manage database resources during upload
This change adds CrashReportDatabase::UploadReport which owns the
report's file handle during upload. An upload is recorded as a success
by calling RecordUploadComplete(). If RecordUploadComplete() is not
called, the operation is recorded as a failure when the UploadReport is
destroyed.

Bug: crashpad:206
Change-Id: I8385d08d52185ad30b06a3ed054de9812ae006a2
Reviewed-on: https://chromium-review.googlesource.com/917983
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2018-02-15 16:21:02 +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
Mark Mentovai
bc7c6e235d mac: Prevent the same report from being uploaded multiple times
With multiple crashpad_handlers running out of the same database, it was
possible for more than one to attempt to upload the same report. Nothing
ensured that the reports remained pending between the calls to
CrashReportDatabaseMac::GetPendingReports() and
CrashReportDatabaseMac::GetReportForUploading().

The Windows equivalent did not share this bug, but it would return
kBusyError. kReportNotFound is a better code.

Test: crashpad_client_test CrashReportDatabaseTest.*
Change-Id: Ieaee7f94ca8e6f2606d000bd2ba508d3cfa2fe07
Reviewed-on: https://chromium-review.googlesource.com/473928
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-04-13 14:12:56 +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
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
Scott Graham
a02ba24006 Convert from scoped_ptr to std::unique_ptr
Follows https://codereview.chromium.org/1911823002/ but fixes includes
that were messed up there.

Change-Id: Ic4bad7d095ee6f5a1c9f8ca2d11ac9e67d55a626
Reviewed-on: https://chromium-review.googlesource.com/340497
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-04-25 19:16:26 +00:00
Mark Mentovai
6d2d31d2d1 Use base/macros.h instead of base/basictypes.h
This was done in Chromium’s local copy of Crashpad in 562827afb599. This
change is similar to that one, except more care was taken to avoid
including headers from a .cc or _test.cc when already included by the
associated .h. Rather than using <stddef.h> for size_t, Crashpad has
always used <sys/types.h>, so that’s used here as well.

This updates mini_chromium to 8a2363f486e3a0dc562a68884832d06d28d38dcc,
which removes base/basictypes.h.

e128dcf10122 Remove base/move.h; use std::move() instead of Pass()
8a2363f486e3 Move basictypes.h to macros.h

R=avi@chromium.org

Review URL: https://codereview.chromium.org/1566713002 .
2016-01-06 12:22:50 -05:00
Mark Mentovai
553a643475 crashpad_database_util: Don’t create a database unless explicitly asked
I’ve accidentally created Crashpad databases when running
crashpad_database_util by mistyping the argument to --database. Typical
users of crashpad_database_util probably don’t want the database to be
created.

This adds a new --create option to crashpad_database_util that is
required to get it to create a database. If not present, a database will
not be created if it does not already exist.

TEST=crashpad_client_test CrashReportDatabaseTest.*
R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/1395653002 .
2015-10-08 13:10:02 -04:00
Robert Sesek
f32ca63a91 Add functionality to prune old crash reports from the database.
BUG=crashpad:22
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1392653002 .
2015-10-07 17:01:47 -04:00
Mark Mentovai
ab23906193 crashpad_database_util: add --new-report.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1018853006
2015-04-03 18:57:01 -04:00
Mark Mentovai
6bf80c3e48 Add MinidumpCrashpadInfo::report_id.
Now that Chrome’s about:crashes displays the crash report UUID, I wanted
to add it to the minidump. In the future, we may be able to index these
on the server. This will also help identify dumps that correspond to the
same event once we’re equipped to convert between different formats.

Ideally, this new field is populated with the same UUID used locally in
the crash report database. To make this work,
CrashReportDatabase::NewReport must carry the UUID. This was actually
part of CrashReportDatabaseWin’s private extension to NewReport, so that
extension subclass can now be cleaned up.

TEST=crashpad_minidump_test MinidumpCrashpadInfoWriter.*,
     crashpad_client_test CrashReportDatabaseTest.NewCrashReport

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1000263003
2015-03-13 13:00:56 -04:00
Mark Mentovai
7d5e17cd2e CrashReportDatabase::Initialize(): use the database path.
Rather than accepting the path to the database’s parent directory, this
now accepts the path to the database itself. Using the parent directory
proved cumbersome in practice. When testing crashpad_handler with a
variety of databases, it is useful to be able to specify
--database=/tmp/crashpad_database, --database=/tmp/crashpad_database_2,
etc. The old interface required that these directories be created as a
separate step, and would put the actual database at
/tmp/crashpad_database/Crashpad. This was contrary to the operation of
most tools and interfaces, which would only require that /tmp exist and
would put the database at /tmp/crashpad_database.

TEST=crashpad_client_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/991393002
2015-03-10 14:27:54 -04:00
Mark Mentovai
4ef649d189 CrashReportDatabse: set the last upload attempt time from RecordUploadAttempt().
This is only implemented for CrashReportDatabaseMac, because
CrashReportDatabaseWin does not currently have a Settings object. See
bug crashpad:13.

TEST=crashpad_client_test CrashReportDatabaseTest.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/995853003
2015-03-10 12:22:31 -04:00
Robert Sesek
1a635e3a79 Define the Settings interface for a CrashReportDatabase and provide a Mac implementation.
R=mark@chromium.org

Review URL: https://codereview.chromium.org/988063003
2015-03-09 18:47:52 -04:00
Mark Mentovai
79177046d3 Mac 10.6 SDK compatibility.
A couple of the problems related to not having a C++11 library:

 - You can’t put const elements into a std::vector<>, so
   CrashReportDatabase::GetPendingReports() and
   CrashReportDatabase::GetCompletedReports() need to change. There was
   no data-safety benefit to const elements.
 - std::string::pop_back() does not exist, another mechanism must be
   used to trim strings in BreakpadHTTPFormParametersFromMinidump().

One relates to a feature that does not exist in 10.6:

 - The O_CLOEXEC flag to open() was introduced in 10.7. Although it
   would be possible to use fcntl(..., F_SETFD, FD_CLOEXEC) on 10.6, the
   O_CLOEXEC behavior is just removed from
   CrashReportDatabaseMac::ObtainReportLock(), in line with other open()
   calls in Crashpad.

And one was a real bug:

 - #define __STDC_FORMAT_MACROS before #including <inttypes.h> to get
   format macros like SCNx32, used in UUID::InitializeFromString().

TEST=* (gyp_crashpad.py -Dmac_sdk=10.6 -Dmac_deployment_target=10.6)
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/987693004
2015-03-06 18:43:28 -05:00
Mark Mentovai
5d0050dee7 Add CrashReportDatabase::ErrorWritingCrashReport().
A crash handler needs a way to clean up after itself it it calls
CrashReportDatabase::PrepareCrashReport() to begin writing a new crash
report, but then encounters an error that renders the crash report
unusable. The new ErrorWritingCrashReport() method allows it to
communicate to the database that a previously-prepared crash report
should be removed without ever being promoted to a completed report
pending upload.

TEST=client_test CrashReportDatabaseTest.ErrorWritingCrashReport
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/904533002
2015-02-04 16:33:15 -05:00
Robert Sesek
ee98449755 Create CrashReportDatabase interface, a test, and a Mac implementation.
R=mark@chromium.org
TEST=client_test --gtest_filter=CrashReportDatabase\*

Review URL: https://codereview.chromium.org/842513002
2015-01-26 15:59:01 -05:00