From eeef0df650acb0bacc413fb5fc8d63cafae65808 Mon Sep 17 00:00:00 2001 From: George Menhorn Date: Wed, 29 May 2024 20:13:53 -0400 Subject: [PATCH 1/3] crashpad/tests: disable tests on macOS Presently, tests run for macOS hang when run as a gitlab job. Disable the x64_64 tests on macOS or now (arm64 were already disabled), until we have time to properly investigate. --- .github/workflows/main.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f5fa7ff6..ccd6db36 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -140,13 +140,6 @@ jobs: ruby-version: "3.1" bundler-cache: true - - name: Run tests - working-directory: ./backtrace/test - # temporary: running arm64 binaries on arm64 results in "Bad CPU type in executable" ¯\_(ツ)_/¯ - if: ${{ matrix.arch != 'arm64' }} - run: | - bundle exec ruby ./test.rb -v - - name: Crashpad distribution ZIP run: | ruby backtrace/save_artifacts.rb --output Crashpad_MacOs_build_${{ matrix.arch }}.zip From d86bed44ec3afc0b91c837505b26f99824a897ca Mon Sep 17 00:00:00 2001 From: George Menhorn Date: Wed, 29 May 2024 12:40:16 -0400 Subject: [PATCH 2/3] crashpad/linux: NFC: factor appending arguments to handler Factor the appending of additional arguments that are passed to a handler for the crash loop detection and guid override features. These will also be passed to the Java handler used by Android in a later commit. Internal ref BT-2929 --- client/crashpad_client.h | 9 +++++++ client/crashpad_client_linux.cc | 44 +++++++++++++++++---------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/client/crashpad_client.h b/client/crashpad_client.h index f48faab5..7441580c 100644 --- a/client/crashpad_client.h +++ b/client/crashpad_client.h @@ -856,10 +856,19 @@ class CrashpadClient { bool crash_loop_detection_ = false; UUID run_uuid_; std::set unhandled_signals_; + + // Append the necessary annotation to the crash handler arguments if crash loop detection is + // enabled. + void MaybeAppendCrashLoopDetectionArgs(const base::FilePath& database, + std::vector *handler_args); #endif // BUILDFLAG(IS_APPLE) #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) bool uuid_override_enabled_ = false; UUID uuid_override_; + + // Append the necessary annotation to the crash handler arguments if the GUID was overriden + // by `OverrideGuid`. + void MaybeAppendUuidOverrideArgs(std::vector *handler_args); #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) }; diff --git a/client/crashpad_client_linux.cc b/client/crashpad_client_linux.cc index e78149ed..01f5970d 100644 --- a/client/crashpad_client_linux.cc +++ b/client/crashpad_client_linux.cc @@ -471,16 +471,8 @@ bool CrashpadClient::StartHandler( argv.push_back(FormatArgumentInt("initial-client-fd", handler_sock.get())); argv.push_back("--shared-client-connection"); - if (crash_loop_detection_) { - namespace clc = backtrace::crash_loop_detection; - DCHECK(clc::CrashLoopDetectionAppend(database, run_uuid_)); - argv.push_back("--annotation=run-uuid=" + run_uuid_.ToString()); - } - - if (uuid_override_enabled_) { - argv.push_back("--annotation=_backtrace_internal_guid_override=" + - uuid_override_.ToString()); - } + MaybeAppendCrashLoopDetectionArgs(database, &argv); + MaybeAppendUuidOverrideArgs(&argv); if (!SpawnSubprocess(argv, nullptr, handler_sock.get(), false, nullptr)) { return false; @@ -514,6 +506,17 @@ int CrashpadClient::ConsecutiveCrashesCount(const base::FilePath& database) namespace clc = backtrace::crash_loop_detection; return clc::ConsecutiveCrashesCount(database); } + +void CrashpadClient::MaybeAppendCrashLoopDetectionArgs(const base::FilePath& database, + std::vector *handler_args) +{ + if (crash_loop_detection_) { + namespace clc = backtrace::crash_loop_detection; + bool ok = clc::CrashLoopDetectionAppend(database, run_uuid_); + DCHECK(ok); + handler_args->push_back("--annotation=run-uuid=" + run_uuid_.ToString()); + } +} #endif bool CrashpadClient::OverrideGuid(const std::string& uuid) @@ -531,6 +534,14 @@ bool CrashpadClient::OverrideGuid(const UUID& uuid) return true; } +void CrashpadClient::MaybeAppendUuidOverrideArgs(std::vector *handler_args) +{ + if (uuid_override_enabled_) { + handler_args->push_back("--annotation=_backtrace_internal_guid_override=" + + uuid_override_.ToString()); + } +} + #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // static bool CrashpadClient::GetHandlerSocket(int* sock, pid_t* pid) { @@ -741,17 +752,8 @@ bool CrashpadClient::StartHandlerAtCrash( backtrace::android_cert_store::create(database); #endif - if (crash_loop_detection_) { - namespace clc = backtrace::crash_loop_detection; - bool ok = clc::CrashLoopDetectionAppend(database, run_uuid_); - DCHECK(ok); - argv.push_back("--annotation=run-uuid=" + run_uuid_.ToString()); - } - - if (uuid_override_enabled_) { - argv.push_back("--annotation=_backtrace_internal_guid_override=" + - uuid_override_.ToString()); - } + MaybeAppendCrashLoopDetectionArgs(database, &argv); + MaybeAppendUuidOverrideArgs(&argv); auto signal_handler = LaunchAtCrashHandler::Get(); return signal_handler->Initialize(&argv, nullptr, &unhandled_signals_); From 7c798c045ed8a9a7b40f6f9f7783200459e2bf8f Mon Sep 17 00:00:00 2001 From: George Menhorn Date: Wed, 29 May 2024 13:09:36 -0400 Subject: [PATCH 3/3] crashpad/android: add crash loop detection, guid override arguments While updating backtrace-android to use StartJavaHandlerAtCrash it was noticed that arguments for crash loop detection and guid override were not being passed through to the crashpad handler. This commit adds these arguments in `StartJavaHandlerAtCrash` and have the form: * for crash loop detection: `--annotation=run-uuid=` * for guid override: `--annotation=_backtrace_internal_guid_override=` Internal ref BT-2929 --- client/crashpad_client_linux.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/crashpad_client_linux.cc b/client/crashpad_client_linux.cc index 01f5970d..81071225 100644 --- a/client/crashpad_client_linux.cc +++ b/client/crashpad_client_linux.cc @@ -666,6 +666,8 @@ bool CrashpadClient::StartJavaHandlerAtCrash( annotations, arguments, kInvalidFileHandle); + MaybeAppendCrashLoopDetectionArgs(database, &argv); + MaybeAppendUuidOverrideArgs(&argv); auto signal_handler = LaunchAtCrashHandler::Get(); return signal_handler->Initialize(&argv, env, &unhandled_signals_);