Skip to content

Commit b670429

Browse files
authored
Merge pull request #76 from supervacuus/meta/update
meta: update 2022-12-12
2 parents a42e249 + 1f23bde commit b670429

20 files changed

+322
-39
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,20 @@ if(CRASHPAD_ZLIB_SYSTEM)
2525
find_package(ZLIB REQUIRED)
2626
endif()
2727

28+
2829
if(LINUX OR ANDROID)
2930
find_package(OpenSSL)
3031
if(OPENSSL_FOUND)
3132
set(CRASHPAD_USE_BORINGSSL ON)
3233
endif()
3334
endif()
3435

36+
if (NOT (ANDROID OR FUCHSIA))
37+
add_compile_definitions(CRASHPAD_FLOCK_ALWAYS_SUPPORTED=1)
38+
else()
39+
add_compile_definitions(CRASHPAD_FLOCK_ALWAYS_SUPPORTED=0)
40+
endif()
41+
3542
include(GNUInstallDirs)
3643
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/crashpad")
3744

DEPS

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
vars = {
1616
'chromium_git': 'https://chromium.googlesource.com',
1717
'gn_version': 'git_revision:2ecd43a10266bd091c98e6dcde507c64f6a0dad3',
18+
# ninja CIPD package version.
19+
# https://chrome-infra-packages.appspot.com/p/infra/3pp/tools/ninja
20+
'ninja_version': 'version:[email protected]',
1821
'pull_linux_clang': False,
1922
'pull_win_toolchain': False,
2023
# Controls whether crashpad/build/ios/setup-ios-gn.py is run as part of
@@ -133,6 +136,51 @@ deps = {
133136
'condition': 'checkout_fuchsia and host_os == "linux"',
134137
'dep_type': 'cipd'
135138
},
139+
# depot_tools/ninja wrapper calls third_party/ninja/{ninja, ninja.exe}.
140+
# crashpad/third_party/ninja/ninja is another wrapper to call linux ninja
141+
# or mac ninja.
142+
# This allows crashpad developers to work for multiple platforms on the same
143+
# machine.
144+
'crashpad/third_party/ninja': {
145+
'packages': [
146+
{
147+
'package': 'infra/3pp/tools/ninja/${{platform}}',
148+
'version': Var('ninja_version'),
149+
}
150+
],
151+
'condition': 'host_os == "win"',
152+
'dep_type': 'cipd',
153+
},
154+
'crashpad/third_party/ninja/linux': {
155+
'packages': [
156+
{
157+
'package': 'infra/3pp/tools/ninja/${{platform}}',
158+
'version': Var('ninja_version'),
159+
}
160+
],
161+
'condition': 'host_os == "linux"',
162+
'dep_type': 'cipd',
163+
},
164+
'crashpad/third_party/ninja/mac-amd64': {
165+
'packages': [
166+
{
167+
'package': 'infra/3pp/tools/ninja/mac-amd64',
168+
'version': Var('ninja_version'),
169+
}
170+
],
171+
'condition': 'host_os == "mac" and host_cpu == "x64"',
172+
'dep_type': 'cipd',
173+
},
174+
'crashpad/third_party/ninja/mac-arm64': {
175+
'packages': [
176+
{
177+
'package': 'infra/3pp/tools/ninja/mac-arm64',
178+
'version': Var('ninja_version'),
179+
}
180+
],
181+
'condition': 'host_os == "mac" and host_cpu == "arm64"',
182+
'dep_type': 'cipd',
183+
},
136184
'crashpad/third_party/win/toolchain': {
137185
# This package is only updated when the solution in .gclient includes an
138186
# entry like:

build/BUILD.gn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ config("crashpad_is_in_fuchsia") {
3030
}
3131
}
3232

33+
config("flock_always_supported_defines") {
34+
defines = [
35+
"CRASHPAD_FLOCK_ALWAYS_SUPPORTED=$crashpad_flock_always_supported",
36+
]
37+
}
38+
3339
group("default_exe_manifest_win") {
3440
if (crashpad_is_in_chromium) {
3541
deps = [ "//build/win:default_exe_manifest" ]

build/crashpad_buildconfig.gni

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ if (crashpad_is_in_chromium) {
8181
crashpad_is_clang = mini_chromium_is_clang
8282
}
8383

84+
crashpad_flock_always_supported = !(crashpad_is_android || crashpad_is_fuchsia)
85+
8486
template("crashpad_executable") {
8587
executable(target_name) {
8688
forward_variables_from(invoker,

client/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static_library("common") {
144144
"../util",
145145
]
146146
deps = [ "../util" ]
147+
configs += [ "../build:flock_always_supported_defines" ]
147148
}
148149

149150
source_set("client_test") {

client/crash_report_database_generic.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,16 @@ int CrashReportDatabaseGeneric::CleanDatabase(time_t lockfile_ttl) {
549549
removed += CleanReportsInState(kPending, lockfile_ttl);
550550
removed += CleanReportsInState(kCompleted, lockfile_ttl);
551551
CleanOrphanedAttachments();
552+
#if !CRASHPAD_FLOCK_ALWAYS_SUPPORTED
553+
base::FilePath settings_path(kSettings);
554+
if (Settings::IsLockExpired(settings_path, lockfile_ttl)) {
555+
base::FilePath lockfile_path(settings_path.value() +
556+
Settings::kLockfileExtension);
557+
if (LoggingRemoveFile(lockfile_path)) {
558+
++removed;
559+
}
560+
}
561+
#endif // !CRASHPAD_FLOCK_ALWAYS_SUPPORTED
552562
return removed;
553563
}
554564

client/crashpad_client_linux.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ class SignalHandler {
180180

181181
DCHECK(!handler_);
182182
handler_ = this;
183-
return Signals::InstallCrashHandlers(
184-
HandleOrReraiseSignal, SA_ONSTACK, &old_actions_, unhandled_signals);
183+
return Signals::InstallCrashHandlers(HandleOrReraiseSignal,
184+
SA_ONSTACK | SA_EXPOSE_TAGBITS,
185+
&old_actions_,
186+
unhandled_signals);
185187
}
186188

187189
const ExceptionInformation& GetExceptionInfo() {

client/crashpad_client_linux_test.cc

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <stdlib.h>
2121
#include <sys/syscall.h>
2222
#include <sys/types.h>
23+
#include <sys/utsname.h>
2324
#include <unistd.h>
2425

2526
#include "base/check_op.h"
@@ -69,6 +70,7 @@ enum class CrashType : uint32_t {
6970
kSimulated,
7071
kBuiltinTrap,
7172
kInfiniteRecursion,
73+
kSegvWithTagBits,
7274
};
7375

7476
struct StartHandlerForSelfTestOptions {
@@ -170,6 +172,10 @@ void ValidateExtraMemory(const StartHandlerForSelfTestOptions& options,
170172
}
171173
}
172174
EXPECT_EQ(pc_found, options.gather_indirectly_referenced_memory);
175+
176+
if (options.crash_type == CrashType::kSegvWithTagBits) {
177+
EXPECT_EQ(exception->ExceptionAddress(), 0xefull << 56);
178+
}
173179
}
174180

175181
void ValidateDump(const StartHandlerForSelfTestOptions& options,
@@ -213,6 +219,12 @@ void ValidateDump(const StartHandlerForSelfTestOptions& options,
213219

214220
#pragma clang diagnostic push
215221
#pragma clang diagnostic ignored "-Winfinite-recursion"
222+
// Clang (masquerading as gcc) is too smart, and removes the recursion
223+
// otherwise. May need to change if either clang or another compiler becomes
224+
// smarter.
225+
#if defined(COMPILER_GCC)
226+
__attribute__((noinline))
227+
#endif
216228
int RecurseInfinitely(int* ptr) {
217229
int buf[1 << 20];
218230
return *ptr + RecurseInfinitely(buf);
@@ -236,16 +248,28 @@ void DoCrash(const StartHandlerForSelfTestOptions& options,
236248
}
237249

238250
switch (options.crash_type) {
239-
case CrashType::kSimulated:
251+
case CrashType::kSimulated: {
240252
CRASHPAD_SIMULATE_CRASH();
241253
break;
254+
}
242255

243-
case CrashType::kBuiltinTrap:
256+
case CrashType::kBuiltinTrap: {
244257
__builtin_trap();
258+
}
245259

246-
case CrashType::kInfiniteRecursion:
260+
case CrashType::kInfiniteRecursion: {
247261
int val = 42;
248262
exit(RecurseInfinitely(&val));
263+
}
264+
265+
case CrashType::kSegvWithTagBits: {
266+
volatile char* x = nullptr;
267+
#ifdef __aarch64__
268+
x += 0xefull << 56;
269+
#endif // __aarch64__
270+
*x;
271+
break;
272+
}
249273
}
250274
}
251275

@@ -268,7 +292,7 @@ class ScopedAltSignalStack {
268292

269293
void Initialize() {
270294
ScopedMmap local_stack_mem;
271-
constexpr size_t stack_size = MINSIGSTKSZ;
295+
const size_t stack_size = MINSIGSTKSZ;
272296
ASSERT_TRUE(local_stack_mem.ResetMmap(nullptr,
273297
stack_size,
274298
PROT_READ | PROT_WRITE,
@@ -410,6 +434,9 @@ class StartHandlerForSelfInChildTest : public MultiprocessExec {
410434
SetExpectedChildTermination(TerminationReason::kTerminationSignal,
411435
SIGSEGV);
412436
break;
437+
case CrashType::kSegvWithTagBits:
438+
SetExpectedChildTermination(TerminationReason::kTerminationSignal,
439+
SIGSEGV);
413440
}
414441
}
415442
}
@@ -486,6 +513,27 @@ TEST_P(StartHandlerForSelfTest, StartHandlerInChild) {
486513
GTEST_SKIP();
487514
}
488515
#endif // defined(ADDRESS_SANITIZER)
516+
517+
if (Options().crash_type == CrashType::kSegvWithTagBits) {
518+
#if !defined(ARCH_CPU_ARM64)
519+
GTEST_SKIP() << "Testing for tag bits only exists on aarch64.";
520+
#else
521+
struct utsname uname_info;
522+
ASSERT_EQ(uname(&uname_info), 0);
523+
ASSERT_NE(uname_info.release, nullptr);
524+
525+
char* release = uname_info.release;
526+
unsigned major = strtoul(release, &release, 10);
527+
ASSERT_EQ(*release++, '.');
528+
unsigned minor = strtoul(release, nullptr, 10);
529+
530+
if (major < 5 || (major == 5 && minor < 11)) {
531+
GTEST_SKIP() << "Linux kernel v" << uname_info.release
532+
<< " does not support SA_EXPOSE_TAGBITS";
533+
}
534+
#endif // !defined(ARCH_CPU_ARM64)
535+
}
536+
489537
StartHandlerForSelfInChildTest test(Options());
490538
test.Run();
491539
}
@@ -500,7 +548,8 @@ INSTANTIATE_TEST_SUITE_P(
500548
testing::Bool(),
501549
testing::Values(CrashType::kSimulated,
502550
CrashType::kBuiltinTrap,
503-
CrashType::kInfiniteRecursion)));
551+
CrashType::kInfiniteRecursion,
552+
CrashType::kSegvWithTagBits)));
504553

505554
// Test state for starting the handler for another process.
506555
class StartHandlerForClientTest {

0 commit comments

Comments
 (0)