17 Commits

Author SHA1 Message Date
Brian Sheedy
bce9a58c66 Fix locking on certain Android partitions
Copy of crrev.com/c/3952963.

Fixes locking not working on some Android filesystems due to flock not
being available. Instead, we now use the same approach as Fuchsia with
a dedicated lock file. This is an issue when running tests on
non-rooted Android devices, as we need files to be written to a
location accessible without root, but the chosen location might not
have flock support.

Bug: chromium:1358240
Change-Id: Ie910481be472403a8b0e9e36100594b0618f85e6
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3999273
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-11-03 22:22:19 +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
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
Justin Cohen
8647761c7d ios: Ensure ScopedLockedFileHandle and UploadReportMac destructor order.
Followup to crrev.com/c/3573184, which did not honor destructor order,
leading to the background task releasing before the lock.

Bug: 1313555
Change-Id: Ifbd3902964552458b83cfc550f50058067021499
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3591012
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-19 22:26:19 +00:00
Justin Cohen
646bba733b ios: Add ScopedBackgroundTask to more flock file access.
Use ScopedBackgroundTask to prevent file lock termination from happening
when holding locked files in a shared AppGroup.

Bug: 1313555
Change-Id: Idc0105f8ecdb65c26214a7265a216b9d480ed01d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3573184
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
2022-04-11 17:00:48 +00:00
Mark Mentovai
1721bb991c Remove unused header <string> from client/settings.h
Change-Id: I04d065f8f77797e6a301dffde30dcfe376e9a48d
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3402639
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-01-19 20:57:45 +00:00
Mark Mentovai
50ed179e9a Use BUILDFLAG for OS checking
Use BUILDFLAG(IS_*) instead of defined(OS_*).

This was generated mostly mechnically by performing the following steps:
 - sed -i '' -E -e 's/defined\(OS_/BUILDFLAG(IS_/g' \
                -e 's%([ !])OS_([A-Z]+)%\1BUILDFLAG(IS_\2)%g' \
       $(git grep -l 'OS_'
         '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm')
 - sed -i '' -e 's/#ifdef BUILDFLAG(/#if BUILDFLAG(/' \
       $(git grep -l '#ifdef BUILDFLAG('
         '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm')
 - gsed -i -z -E -e \
       's%(.*)#include "%\1#include "build/buildflag.h"\n#include "%' \
       $(git grep -l 'BUILDFLAG(IS_'
         '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm')
 - Spot checks to move #include "build/buildflag.h" to the correct parts
   of files.
 - sed -i '' -E -e \
       's%^(#include "build/buildflag.h")$%#include "build/build_config.h"\n\1%' \
       $(grep -L '^#include "build/build_config.h"$'
         $(git grep -l 'BUILDFLAG(IS_'
           '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm'))
 - Add “clang-format off” around tool usage messages.
 - git cl format
 - Update mini_chromium to 85ba51f98278 (intermediate step).
   TESTING ONLY).
 - for f in $(git grep -l '^#include "build/buildflag.h"$'
              '**/*.c' '**/*.cc' '**/*.h' '**/*.m' '**/*.mm'); do \
       grep -v '^#include "build/buildflag.h"$' "${f}" > /tmp/z; \
       cp /tmp/z "${f}"; done
 - git cl format
 - Update mini_chromium to 735143774c5f (intermediate step).
 - Update mini_chromium to f41420eb45fa (as checked in).
 - Update mini_chromium to 6e2f204b4ae1 (as checked in).

For ease of review and inspection, each of these steps is uploaded as a
new patch set in a review series.

This includes an update of mini_chromium to 6e2f204b4ae1:

f41420eb45fa Use BUILDFLAG for OS checking
6e2f204b4ae1 Include what you use: string_util.h uses build_config.h

Bug: chromium:1234043
Change-Id: Ieef86186f094c64e59b853729737e36982f8cf69
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3400258
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-01-19 20:21: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
Ian Barkley-Yeung
5779e638e1 Note that uploads consent is ignored on ChromeOS
Note that upload consent is ignored if --use-cros-crash-reporter is
present, which it will be if invoked by Chrome on ChromeOS.

BUG=chromium:1037656
TEST=None

Change-Id: I2dcea736de40a082b477f21d46c3ed01f1d91699
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2042317
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Ian Barkley-Yeung <iby@chromium.org>
2020-02-06 23:35:21 +00:00
Scott Graham
5cb869392e fuchsia: Compile out LoggingLock/UnlockFile, add DCHECKs to Settings
Fuchsia does not currently support any sort of file locking. Until a
lock server can be implemented, compile out the calls to flock(). In the
one current non-test user of locking (Settings) add a
pseudo-implementation that will DCHECK if there is ever contention on
the lock.

Bug: crashpad:217, crashpad:196
Change-Id: Ifdf7e00886ad7e7778745f1ae8f0ce2a86f0ae3b
Reviewed-on: https://chromium-review.googlesource.com/924312
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-16 20:58:38 +00:00
Scott Graham
e5bbdaff87 Pass FilePath to Settings in Initialize()
Pulled out of jperaza's https://crrev.com/c/689745.

Future updates to the CrashReportDatabase would like to be decide on the
Settings location later than the constructor, but still keep the Settings
object embedded inline. To allow this, pass the location FilePath in
Initialize() rather than to the constructor.

Bug: crashpad:206
Change-Id: I8792188314541f6fd0bd04b168d22f8e445bc187
Reviewed-on: https://chromium-review.googlesource.com/916533
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-13 22:28:55 +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
81ece89d6a Make ScopedGeneric uses slightly more consistent
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1426533008 .
2015-11-09 15:33:36 -05:00
Mark Mentovai
0884d4d3a8 Don’t log an error when creating a new crash report database
Previously, any attempt to create a new crash report database would
result in this message being logged:

[p:t:yyyymmdd,hhmmss.uuuuuu:ERROR file_io.cc:30] read: expected 40,
observed 0

This would be the first thing that a developer embedding Crashpad into
their application would see after getting everything right. It doesn’t
exactly seem like everything’s right with that being logged. It would
also be the first thing that a user would see on stderr or in logs upon
launching a Crashpad-enabled application, which also seems kind of
dodgy.

The crash report database settings creation logic is restructured to
avoid logging this error when definitely creating a new database, while
retaining all other error logging.

BUG=crashpad:63
TEST=crashpad_database_util --database $new_db --show-client-id
     (should not show any errors)

R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/1392953002 .
2015-10-07 16:20:29 -04:00
Scott Graham
8272a4cefe Use LockFile/UnlockFile for Settings to port to Windows
Adds LoggingOpenFileForReadAndWrite, LoggingTruncateFile, and UUID::GenerateFromSystem
in support.

R=mark@chromium.org, rsesek@chromium.org
BUG=crashpad:13

Review URL: https://codereview.chromium.org/999953002
2015-04-20 14:21:48 -07:00
Mark Mentovai
bdcc1e7625 Return a FilePath from Settings::file_path().
This makes it possible to #include "client/settings.h" for the interface
even on Windows. Although Settings is not currently implemented on
Windows (bug crashpad:13), it’s easier to have the interface declaration
available without having to have it be guarded.

TEST=crashpad_client_test SettingsTest.*
BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/987383002
2015-03-10 14:26:24 -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