diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 10:22:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:36:28 +0000 |
commit | 271a6c3487a14599023a9106329505597638d793 (patch) | |
tree | e040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/components/crash | |
parent | 7b2ffa587235a47d4094787d72f38102089f402a (diff) | |
download | qtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz |
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/crash')
27 files changed, 211 insertions, 38 deletions
diff --git a/chromium/components/crash/android/BUILD.gn b/chromium/components/crash/android/BUILD.gn index c61e6713ed9..53c02f3b284 100644 --- a/chromium/components/crash/android/BUILD.gn +++ b/chromium/components/crash/android/BUILD.gn @@ -12,7 +12,6 @@ _jni_sources = [ generate_jni("jni_headers") { sources = _jni_sources - jni_package = "crash" } java_cpp_enum("java_enums_srcjar") { @@ -58,7 +57,6 @@ _java_handler_jni_sources = generate_jni("java_handler_jni_headers") { sources = _java_handler_jni_sources - jni_package = "crashpad" } android_library("handler_java") { diff --git a/chromium/components/crash/android/DEPS b/chromium/components/crash/android/DEPS index fb4880eab96..56e7e235177 100644 --- a/chromium/components/crash/android/DEPS +++ b/chromium/components/crash/android/DEPS @@ -1,4 +1,4 @@ include_rules = [ - "+jni", + "+components/crash/android/jni_headers", "+third_party/crashpad", ] diff --git a/chromium/components/crash/android/crash_keys_android.cc b/chromium/components/crash/android/crash_keys_android.cc index 64e5b5bd518..26932a816a5 100644 --- a/chromium/components/crash/android/crash_keys_android.cc +++ b/chromium/components/crash/android/crash_keys_android.cc @@ -6,8 +6,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "components/crash/android/jni_headers/CrashKeys_jni.h" #include "components/crash/core/common/crash_key.h" -#include "jni/CrashKeys_jni.h" namespace { diff --git a/chromium/components/crash/android/crashpad_main.cc b/chromium/components/crash/android/crashpad_main.cc index ce3d8888fb8..8fc9b5586cf 100644 --- a/chromium/components/crash/android/crashpad_main.cc +++ b/chromium/components/crash/android/crashpad_main.cc @@ -4,7 +4,7 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" -#include "jni/CrashpadMain_jni.h" +#include "components/crash/android/java_handler_jni_headers/CrashpadMain_jni.h" #include "third_party/crashpad/crashpad/client/client_argv_handling.h" #include "third_party/crashpad/crashpad/handler/handler_main.h" @@ -19,7 +19,7 @@ static void JNI_CrashpadMain_CrashpadMain( std::vector<const char*> argv; StringVectorToCStringVector(argv_strings, &argv); - HandlerMain(argv.size() - 1, const_cast<char**>(argv.data()), nullptr); + CrashpadHandlerMain(argv.size() - 1, const_cast<char**>(argv.data())); } } // namespace crashpad diff --git a/chromium/components/crash/content/app/BUILD.gn b/chromium/components/crash/content/app/BUILD.gn index 89842dd2bcf..529131ef392 100644 --- a/chromium/components/crash/content/app/BUILD.gn +++ b/chromium/components/crash/content/app/BUILD.gn @@ -5,6 +5,8 @@ # TODO(crbug.com/753619): Enable crash reporting on Fuchsia. assert(!is_ios && !is_fuchsia) +import("//components/gwp_asan/buildflags/buildflags.gni") + if (is_android) { import("//build/config/android/config.gni") } @@ -22,6 +24,21 @@ source_set("lib") { ] } +source_set("crashpad_handler_main") { + sources = [ + "crashpad_handler_main.cc", + ] + + deps = [ + "//components/gwp_asan/buildflags", + "//third_party/crashpad/crashpad/handler:handler", + ] + + if (enable_gwp_asan) { + deps += [ "//components/gwp_asan/crash_handler" ] + } +} + static_library("app") { sources = [ "crash_export_thunks.h", @@ -63,6 +80,7 @@ static_library("app") { if (is_android) { deps += [ + ":crashpad_handler_main", "//components/crash/android:jni_headers", "//third_party/crashpad/crashpad/handler", "//third_party/crashpad/crashpad/snapshot", @@ -79,7 +97,10 @@ static_library("app") { ] if (is_linux) { - deps += [ "//third_party/breakpad:client" ] + deps += [ + "//content/public/common", + "//third_party/breakpad:client", + ] } } @@ -131,12 +152,16 @@ if (is_win) { deps = [ "//base", "//components/browser_watcher:crash_stability", - "//components/gwp_asan/crash_handler", + "//components/gwp_asan/buildflags", "//third_party/crashpad/crashpad/client", "//third_party/crashpad/crashpad/handler", "//third_party/crashpad/crashpad/minidump", "//third_party/crashpad/crashpad/util", ] + + if (enable_gwp_asan) { + deps += [ "//components/gwp_asan/crash_handler" ] + } } # This source set contains the include file that declares the export thunks. @@ -197,10 +222,14 @@ if (is_mac) { ] deps = [ - "//components/gwp_asan/crash_handler", + "//components/gwp_asan/buildflags", "//third_party/crashpad/crashpad/handler:handler", ] + if (enable_gwp_asan) { + deps += [ "//components/gwp_asan/crash_handler" ] + } + if (is_component_build) { ldflags = [ # The handler is in diff --git a/chromium/components/crash/content/app/DEPS b/chromium/components/crash/content/app/DEPS index 63e5b6fcabf..d89b50ecf30 100644 --- a/chromium/components/crash/content/app/DEPS +++ b/chromium/components/crash/content/app/DEPS @@ -1,11 +1,14 @@ include_rules = [ "+sandbox", + "+components/crash/android/jni_headers", "+components/browser_watcher/stability_report_user_stream_data_source.h", + "+components/gwp_asan/buildflags/buildflags.h", "+components/gwp_asan/crash_handler/crash_handler.h", "+content/public/common/content_descriptors.h", + "+content/public/common/content_switches.h", "+content/public/common/result_codes.h", - "+jni", + "+services/service_manager/embedder/switches.h", "+third_party/crashpad", "+third_party/lss/linux_syscall_support.h", ] diff --git a/chromium/components/crash/content/app/breakpad_linux.cc b/chromium/components/crash/content/app/breakpad_linux.cc index 3ab8ad2c5aa..bb5ee46d3f2 100644 --- a/chromium/components/crash/content/app/breakpad_linux.cc +++ b/chromium/components/crash/content/app/breakpad_linux.cc @@ -36,6 +36,7 @@ #include "base/posix/eintr_wrapper.h" #include "base/posix/global_descriptors.h" #include "base/process/memory.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/threading/thread_checker.h" @@ -44,6 +45,8 @@ #include "components/crash/content/app/crash_reporter_client.h" #include "components/crash/core/common/crash_keys.h" #include "content/public/common/content_descriptors.h" +#include "content/public/common/content_switches.h" +#include "services/service_manager/embedder/switches.h" #include "third_party/breakpad/breakpad/src/client/linux/crash_generation/crash_generation_client.h" #include "third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h" #include "third_party/breakpad/breakpad/src/client/linux/minidump_writer/directory_reader.h" @@ -87,7 +90,16 @@ namespace breakpad { namespace { -#if !defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) +// An optional UNIX timestamp passed to us from session_manager. If set, +// session_manager thinks we are in a possible crash-loop and will log the user +// out if we crash again before the indicated time. We don't actually do much +// with this value, just pass it along to crash_reporter. This should really +// be a time_t, but it's basically an opaque value (we don't anything with it +// except pass it along) and we don't have functions to deal with time_t's well, +// while we do have functions to deal with uint64_t's. +uint64_t g_crash_loop_before_time = 0; +#else const char kUploadURL[] = "https://clients2.google.com/cr/report"; #endif @@ -1131,11 +1143,35 @@ void InitCrashKeys() { g_crash_key_white_list = GetCrashReporterClient()->GetCrashKeyWhiteList(); } +void SetCrashLoopBeforeTime(const std::string& process_type, + const base::CommandLine& parsed_command_line) { +#if defined(OS_CHROMEOS) + if (!ShouldPassCrashLoopBefore(process_type)) { + return; + } + + std::string crash_loop_before = + parsed_command_line.GetSwitchValueASCII(switches::kCrashLoopBefore); + if (crash_loop_before.empty()) { + return; + } + + if (!base::StringToUint64(crash_loop_before, &g_crash_loop_before_time)) { + LOG(WARNING) << "Could not convert --crash-loop-before=" + << crash_loop_before << " to integer"; + g_crash_loop_before_time = 0; + } +#endif // defined(OS_CHROMEOS) +} + // Miscellaneous initialization functions to call after Breakpad has been // enabled. -void PostEnableBreakpadInitialization() { +void PostEnableBreakpadInitialization( + const std::string& process_type, + const base::CommandLine& parsed_command_line) { SetProcessStartTime(); g_pid = getpid(); + SetCrashLoopBeforeTime(process_type, parsed_command_line); base::debug::SetDumpWithoutCrashingFunction(&DumpProcess); #if defined(ADDRESS_SANITIZER) @@ -1265,13 +1301,20 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info, my_strlcat(exe_flag, kExeBuf, buf_len); my_strlcat(exe_flag, exe_buf, buf_len); + char* crash_loop_before_flag = nullptr; + if (g_crash_loop_before_time != 0) { + crash_loop_before_flag = StringFromPrefixAndUint( + "--crash_loop_before=", g_crash_loop_before_time, allocator); + } + const char* args[] = { - kCrashReporterBinary, - chrome_flag, - pid_flag, - uid_flag, - exe_flag, - nullptr, + kCrashReporterBinary, + chrome_flag, + pid_flag, + uid_flag, + exe_flag, + crash_loop_before_flag, // Leave last, might be nullptr. + nullptr, }; static const char msg[] = "Cannot upload crash dump: cannot exec " "/sbin/crash_reporter\n"; @@ -1509,7 +1552,7 @@ const char* GetCrashingProcessName(const BreakpadInfo& info, // Either way too long, or a read error. return "chrome-crash-unknown-process"; } -#endif +#endif // defined(OS_CHROMEOS) // Attempts to close all open file descriptors other than stdin, stdout and // stderr (0, 1, and 2). @@ -2024,7 +2067,7 @@ void InitCrashReporter(const std::string& process_type) { #endif // #if defined(OS_ANDROID) } - PostEnableBreakpadInitialization(); + PostEnableBreakpadInitialization(process_type, parsed_command_line); } void SetChannelCrashKey(const std::string& channel) { @@ -2118,6 +2161,21 @@ void SuppressDumpGeneration() { } #endif // OS_ANDROID +#if defined(OS_CHROMEOS) +bool ShouldPassCrashLoopBefore(const std::string& process_type) { + if (process_type == ::switches::kRendererProcess || + process_type == ::switches::kUtilityProcess || + process_type == ::switches::kPpapiPluginProcess || + process_type == service_manager::switches::kZygoteProcess) { + // These process types never cause a log-out, even if they crash. So the + // normal crash handling process should work fine; we shouldn't need to + // invoke the special crash-loop mode. + return false; + } + return true; +} +#endif // defined(OS_CHROMEOS) + bool IsCrashReporterEnabled() { return g_is_crash_reporter_enabled; } diff --git a/chromium/components/crash/content/app/breakpad_linux.h b/chromium/components/crash/content/app/breakpad_linux.h index 6e95af6ca7f..fb7f0a8af26 100644 --- a/chromium/components/crash/content/app/breakpad_linux.h +++ b/chromium/components/crash/content/app/breakpad_linux.h @@ -58,6 +58,13 @@ extern void AddGpuFingerprintToMicrodumpCrashHandler( extern void SuppressDumpGeneration(); #endif // defined(OS_ANDROID) +#if defined(OS_CHROMEOS) +// If true, processes of this type should pass crash-loop-before down to the +// crash reporter and to their children (if the children's type is a process +// type that wants crash-loop-before). +bool ShouldPassCrashLoopBefore(const std::string& process_type); +#endif + // Checks if crash reporting is enabled. Note that this is not the same as // being opted into metrics reporting (and crash reporting), which controls // whether InitCrashReporter() is called. diff --git a/chromium/components/crash/content/app/chrome_crashpad_handler.cc b/chromium/components/crash/content/app/chrome_crashpad_handler.cc index 24a83887ac8..c4b629d8263 100644 --- a/chromium/components/crash/content/app/chrome_crashpad_handler.cc +++ b/chromium/components/crash/content/app/chrome_crashpad_handler.cc @@ -4,14 +4,20 @@ #include <memory> -#include "components/gwp_asan/crash_handler/crash_handler.h" +#include "components/gwp_asan/buildflags/buildflags.h" #include "third_party/crashpad/crashpad/handler/handler_main.h" #include "third_party/crashpad/crashpad/handler/user_stream_data_source.h" +#if BUILDFLAG(ENABLE_GWP_ASAN) +#include "components/gwp_asan/crash_handler/crash_handler.h" +#endif + int main(int argc, char* argv[]) { crashpad::UserStreamDataSources user_stream_data_sources; +#if BUILDFLAG(ENABLE_GWP_ASAN) user_stream_data_sources.push_back( std::make_unique<gwp_asan::UserStreamDataSource>()); +#endif return crashpad::HandlerMain(argc, argv, &user_stream_data_sources); } diff --git a/chromium/components/crash/content/app/crashpad_android.cc b/chromium/components/crash/content/app/crashpad_android.cc index 9551b90bb48..991120a9fb1 100644 --- a/chromium/components/crash/content/app/crashpad_android.cc +++ b/chromium/components/crash/content/app/crashpad_android.cc @@ -31,9 +31,9 @@ #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" +#include "components/crash/android/jni_headers/PackagePaths_jni.h" #include "components/crash/content/app/crash_reporter_client.h" #include "content/public/common/content_descriptors.h" -#include "jni/PackagePaths_jni.h" #include "sandbox/linux/services/syscall_wrappers.h" #include "third_party/crashpad/crashpad/client/annotation.h" #include "third_party/crashpad/crashpad/client/client_argv_handling.h" diff --git a/chromium/components/crash/content/app/crashpad_handler_main.cc b/chromium/components/crash/content/app/crashpad_handler_main.cc new file mode 100644 index 00000000000..3f04a1f76fc --- /dev/null +++ b/chromium/components/crash/content/app/crashpad_handler_main.cc @@ -0,0 +1,29 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <memory> + +#include "components/gwp_asan/buildflags/buildflags.h" +#include "third_party/crashpad/crashpad/handler/handler_main.h" +#include "third_party/crashpad/crashpad/handler/user_stream_data_source.h" + +#if BUILDFLAG(ENABLE_GWP_ASAN) +#include "components/gwp_asan/crash_handler/crash_handler.h" // nogncheck +#endif + +extern "C" { + +__attribute__((visibility("default"), used)) int CrashpadHandlerMain( + int argc, + char* argv[]) { + crashpad::UserStreamDataSources user_stream_data_sources; +#if BUILDFLAG(ENABLE_GWP_ASAN) + user_stream_data_sources.push_back( + std::make_unique<gwp_asan::UserStreamDataSource>()); +#endif + + return crashpad::HandlerMain(argc, argv, &user_stream_data_sources); +} + +} // extern "C" diff --git a/chromium/components/crash/content/app/run_as_crashpad_handler_win.cc b/chromium/components/crash/content/app/run_as_crashpad_handler_win.cc index 29481567d9c..2192d06fae6 100644 --- a/chromium/components/crash/content/app/run_as_crashpad_handler_win.cc +++ b/chromium/components/crash/content/app/run_as_crashpad_handler_win.cc @@ -16,12 +16,16 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "components/browser_watcher/stability_report_user_stream_data_source.h" -#include "components/gwp_asan/crash_handler/crash_handler.h" +#include "components/gwp_asan/buildflags/buildflags.h" #include "third_party/crashpad/crashpad/client/crashpad_info.h" #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" #include "third_party/crashpad/crashpad/handler/handler_main.h" #include "third_party/crashpad/crashpad/handler/user_stream_data_source.h" +#if BUILDFLAG(ENABLE_GWP_ASAN) +#include "components/gwp_asan/crash_handler/crash_handler.h" // nogncheck +#endif + namespace crash_reporter { int RunAsCrashpadHandler(const base::CommandLine& command_line, @@ -84,8 +88,10 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line, user_data_dir)); } +#if BUILDFLAG(ENABLE_GWP_ASAN) user_stream_data_sources.push_back( std::make_unique<gwp_asan::UserStreamDataSource>()); +#endif return crashpad::HandlerMain(static_cast<int>(storage.size()), argv_as_utf8.get(), &user_stream_data_sources); diff --git a/chromium/components/crash/content/browser/DEPS b/chromium/components/crash/content/browser/DEPS index 7f2b333265f..77854b43bfe 100644 --- a/chromium/components/crash/content/browser/DEPS +++ b/chromium/components/crash/content/browser/DEPS @@ -1,8 +1,8 @@ include_rules = [ + "+components/crash/android/jni_headers", "+content/public/browser", "+content/public/common", "+content/public/test", - "+jni", "+mojo/public/cpp/bindings", "+third_party/blink/public/mojom/crash/crash_memory_metrics_reporter.mojom.h", "+third_party/blink/public/common/oom_intervention" diff --git a/chromium/components/crash/content/browser/child_exit_observer_android.cc b/chromium/components/crash/content/browser/child_exit_observer_android.cc index aee39990e59..41f904e9ce0 100644 --- a/chromium/components/crash/content/browser/child_exit_observer_android.cc +++ b/chromium/components/crash/content/browser/child_exit_observer_android.cc @@ -156,7 +156,7 @@ void ChildExitObserver::BrowserChildProcessKilled( const content::ChildProcessData& data, const content::ChildProcessTerminationInfo& content_info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - DCHECK(!base::ContainsKey(browser_child_process_info_, data.id)); + DCHECK(!base::Contains(browser_child_process_info_, data.id)); TerminationInfo info; info.process_host_id = data.id; info.pid = data.GetProcess().Pid(); diff --git a/chromium/components/crash/content/browser/child_process_crash_observer_android.cc b/chromium/components/crash/content/browser/child_process_crash_observer_android.cc index 33451d4efc7..814f70409c6 100644 --- a/chromium/components/crash/content/browser/child_process_crash_observer_android.cc +++ b/chromium/components/crash/content/browser/child_process_crash_observer_android.cc @@ -9,8 +9,8 @@ #include "base/task/post_task.h" #include "base/task/task_traits.h" #include "base/threading/scoped_blocking_call.h" +#include "components/crash/android/jni_headers/ChildProcessCrashObserver_jni.h" #include "components/crash/content/browser/crash_metrics_reporter_android.h" -#include "jni/ChildProcessCrashObserver_jni.h" namespace crash_reporter { diff --git a/chromium/components/crash/content/browser/crash_metrics_reporter_android_unittest.cc b/chromium/components/crash/content/browser/crash_metrics_reporter_android_unittest.cc index a01347fb043..97330caf702 100644 --- a/chromium/components/crash/content/browser/crash_metrics_reporter_android_unittest.cc +++ b/chromium/components/crash/content/browser/crash_metrics_reporter_android_unittest.cc @@ -26,7 +26,7 @@ class CrashMetricsReporterObserver : public CrashMetricsReporter::Observer { const CrashMetricsReporter::ReportedCrashTypeSet& reported_counts) override { recorded_crash_types_ = reported_counts; - wait_run_loop_.QuitClosure().Run(); + wait_run_loop_.Quit(); } const CrashMetricsReporter::ReportedCrashTypeSet& recorded_crash_types() diff --git a/chromium/components/crash/core/browser/resources/OWNERS b/chromium/components/crash/core/browser/resources/OWNERS new file mode 100644 index 00000000000..c05db2e16e1 --- /dev/null +++ b/chromium/components/crash/core/browser/resources/OWNERS @@ -0,0 +1,2 @@ +# For trivial or mechanical horizontal JS/CSS/HTML changes. +file://ui/webui/PLATFORM_OWNERS diff --git a/chromium/components/crash/core/common/BUILD.gn b/chromium/components/crash/core/common/BUILD.gn index 8caf17a127b..3d42df91faa 100644 --- a/chromium/components/crash/core/common/BUILD.gn +++ b/chromium/components/crash/core/common/BUILD.gn @@ -153,7 +153,7 @@ source_set("unit_tests") { sources += [ "objc_zombie_unittest.mm" ] } - if (!is_mac && !is_win && !is_fuchsia && !is_android) { + if (!is_mac && !is_ios && !is_win && !is_fuchsia && !is_android) { include_dirs = [ "//third_party/breakpad/breakpad/src/" ] sources += [ "crash_key_breakpad_unittest.cc" ] } diff --git a/chromium/components/crash/core/common/crash_key.h b/chromium/components/crash/core/common/crash_key.h index a38e24ca14d..2118ebdb4e8 100644 --- a/chromium/components/crash/core/common/crash_key.h +++ b/chromium/components/crash/core/common/crash_key.h @@ -226,6 +226,10 @@ CRASH_KEY_EXPORT void InitializeCrashKeys(); // current component. CRASH_KEY_EXPORT std::string GetCrashKeyValue(const std::string& key_name); +// Initializes the crash key subsystem with testing configuration if it is +// required. +CRASH_KEY_EXPORT void InitializeCrashKeysForTesting(); + // Resets crash key state and, depending on the platform, de-initializes // the system. CRASH_KEY_EXPORT void ResetCrashKeysForTesting(); diff --git a/chromium/components/crash/core/common/crash_key_breakpad.cc b/chromium/components/crash/core/common/crash_key_breakpad.cc index 0351e01fa18..78f275f0031 100644 --- a/chromium/components/crash/core/common/crash_key_breakpad.cc +++ b/chromium/components/crash/core/common/crash_key_breakpad.cc @@ -144,6 +144,10 @@ std::string GetCrashKeyValue(const std::string& key_name) { return std::string(); } +void InitializeCrashKeysForTesting() { + InitializeCrashKeys(); +} + void ResetCrashKeysForTesting() { internal::ResetCrashKeyStorageForTesting(); base::debug::SetCrashKeyImplementation(nullptr); diff --git a/chromium/components/crash/core/common/crash_key_breakpad_ios.mm b/chromium/components/crash/core/common/crash_key_breakpad_ios.mm index b0625176f38..b4099df2e28 100644 --- a/chromium/components/crash/core/common/crash_key_breakpad_ios.mm +++ b/chromium/components/crash/core/common/crash_key_breakpad_ios.mm @@ -95,9 +95,16 @@ std::string GetCrashKeyValue(const std::string& key_name) { return base::SysNSStringToUTF8(value); } +void InitializeCrashKeysForTesting() { + [[BreakpadController sharedInstance] updateConfiguration:@{ + @BREAKPAD_URL : @"http://breakpad.test" + }]; + [[BreakpadController sharedInstance] start:YES]; + InitializeCrashKeys(); +} + void ResetCrashKeysForTesting() { - // There's no way to do this on iOS without tearing down the - // BreakpadController. + [[BreakpadController sharedInstance] stop]; } } // namespace crash_reporter diff --git a/chromium/components/crash/core/common/crash_key_breakpad_unittest.cc b/chromium/components/crash/core/common/crash_key_breakpad_unittest.cc index e07776607f5..4e3e71e2374 100644 --- a/chromium/components/crash/core/common/crash_key_breakpad_unittest.cc +++ b/chromium/components/crash/core/common/crash_key_breakpad_unittest.cc @@ -12,6 +12,7 @@ namespace crash_reporter { class CrashKeyBreakpadTest : public testing::Test { public: void SetUp() override { + internal::ResetCrashKeyStorageForTesting(); InitializeCrashKeys(); ASSERT_TRUE(internal::GetCrashKeyStorage()); } diff --git a/chromium/components/crash/core/common/crash_key_crashpad.cc b/chromium/components/crash/core/common/crash_key_crashpad.cc index c6b074897c5..66fd94d4a14 100644 --- a/chromium/components/crash/core/common/crash_key_crashpad.cc +++ b/chromium/components/crash/core/common/crash_key_crashpad.cc @@ -35,6 +35,10 @@ std::string GetCrashKeyValue(const std::string& key_name) { return std::string(); } +void InitializeCrashKeysForTesting() { + InitializeCrashKeys(); +} + void ResetCrashKeysForTesting() { // The AnnotationList should not be deleted because the static Annotation // object data still reference the link nodes. diff --git a/chromium/components/crash/core/common/crash_key_stubs.cc b/chromium/components/crash/core/common/crash_key_stubs.cc index 77fe36e7572..c2867150597 100644 --- a/chromium/components/crash/core/common/crash_key_stubs.cc +++ b/chromium/components/crash/core/common/crash_key_stubs.cc @@ -32,6 +32,8 @@ std::string GetCrashKeyValue(const std::string& key_name) { return std::string(); } +void InitializeCrashKeysForTesting() {} + void ResetCrashKeysForTesting() {} } // namespace crash_reporter diff --git a/chromium/components/crash/core/common/crash_key_unittest.cc b/chromium/components/crash/core/common/crash_key_unittest.cc index cb9ad9660d6..3e7f1023aab 100644 --- a/chromium/components/crash/core/common/crash_key_unittest.cc +++ b/chromium/components/crash/core/common/crash_key_unittest.cc @@ -15,7 +15,9 @@ namespace { class CrashKeyStringTest : public testing::Test { public: - void SetUp() override { InitializeCrashKeys(); } + void SetUp() override { InitializeCrashKeysForTesting(); } + + void TearDown() override { ResetCrashKeysForTesting(); } }; TEST_F(CrashKeyStringTest, ScopedCrashKeyString) { diff --git a/chromium/components/crash/core/common/crash_keys_unittest.cc b/chromium/components/crash/core/common/crash_keys_unittest.cc index 603cc36c8b3..82eb5cdd10a 100644 --- a/chromium/components/crash/core/common/crash_keys_unittest.cc +++ b/chromium/components/crash/core/common/crash_keys_unittest.cc @@ -24,7 +24,7 @@ class CrashKeysTest : public testing::Test { public: void SetUp() override { ResetData(); - crash_reporter::InitializeCrashKeys(); + crash_reporter::InitializeCrashKeysForTesting(); } void TearDown() override { diff --git a/chromium/components/crash/core/common/objc_zombie.mm b/chromium/components/crash/core/common/objc_zombie.mm index 70e47a29fd2..3df847911f8 100644 --- a/chromium/components/crash/core/common/objc_zombie.mm +++ b/chromium/components/crash/core/common/objc_zombie.mm @@ -56,7 +56,17 @@ namespace { const size_t kBacktraceDepth = 20; // The original implementation for |-[NSObject dealloc]|. -IMP g_originalDeallocIMP = NULL; +#if OBJC_OLD_DISPATCH_PROTOTYPES +using RealIMP = IMP; +#else +// With !OBJC_OLD_DISPATCH_PROTOTYPES the runtime hasn't changed and IMP is +// still what it always was, but the SDK is hiding the details now outside the +// objc runtime. It is safe to define |RealIMP| to match the older definition of +// |IMP|. +using RealIMP = id (*)(id, SEL, ...); +#endif + +RealIMP g_originalDeallocIMP = NULL; // Classes which freed objects become. |g_fatZombieSize| is the // minimum object size which can be made into a fat zombie (which can @@ -252,8 +262,8 @@ BOOL ZombieInit() { return YES; Class rootClass = [NSObject class]; - g_originalDeallocIMP = - class_getMethodImplementation(rootClass, @selector(dealloc)); + g_originalDeallocIMP = reinterpret_cast<RealIMP>( + class_getMethodImplementation(rootClass, @selector(dealloc))); // objc_getClass() so CrZombie doesn't need +class. g_zombieClass = objc_getClass("CrZombie"); g_fatZombieClass = objc_getClass("CrFatZombie"); @@ -346,9 +356,10 @@ bool ZombieEnable(bool zombieAllObjects, if (!m) return false; - const IMP prevDeallocIMP = method_setImplementation(m, (IMP)ZombieDealloc); + const RealIMP prevDeallocIMP = reinterpret_cast<RealIMP>( + method_setImplementation(m, reinterpret_cast<IMP>(ZombieDealloc))); DCHECK(prevDeallocIMP == g_originalDeallocIMP || - prevDeallocIMP == (IMP)ZombieDealloc); + prevDeallocIMP == reinterpret_cast<RealIMP>(ZombieDealloc)); // Grab the current set of zombies. This is thread-safe because // only the main thread can change these. @@ -420,7 +431,7 @@ void ZombieDisable() { // Put back the original implementation of -[NSObject dealloc]. Method m = class_getInstanceMethod([NSObject class], @selector(dealloc)); DCHECK(m); - method_setImplementation(m, g_originalDeallocIMP); + method_setImplementation(m, reinterpret_cast<IMP>(g_originalDeallocIMP)); // Can safely grab this because it only happens on the main thread. const size_t oldCount = g_zombieCount; |