diff options
author | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-28 17:15:48 +0000 |
---|---|---|
committer | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-28 17:15:48 +0000 |
commit | ca190c8dbed8e86e31dc8807824527395bdcfd4e (patch) | |
tree | 0d07d972cfb00a0dd8dafb7827e5e5388cef0f92 | |
parent | 6cec1ea63ac87acf05093b41fe826c94e08e8473 (diff) | |
download | chromium_src-ca190c8dbed8e86e31dc8807824527395bdcfd4e.zip chromium_src-ca190c8dbed8e86e31dc8807824527395bdcfd4e.tar.gz chromium_src-ca190c8dbed8e86e31dc8807824527395bdcfd4e.tar.bz2 |
Experimentally disable termination on heap corruption in order to measure the contribution of this feature to missing crash reports.
Because this feature is configured very early in the process lifetime it cannot be directly controlled by a field-trial. Rather, we query the status during a given execution, store that status in the registry, and then query the registry during startup. This means the experiment will only take effect the 2nd time it is executed.
BUG=394842
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=284100
Review URL: https://codereview.chromium.org/402723002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285931 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/chrome_main.cc | 4 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_win.cc | 5 | ||||
-rw-r--r-- | chrome/chrome_common.gypi | 2 | ||||
-rw-r--r-- | chrome/common/terminate_on_heap_corruption_experiment_win.cc | 66 | ||||
-rw-r--r-- | chrome/common/terminate_on_heap_corruption_experiment_win.h | 11 | ||||
-rw-r--r-- | content/app/content_main_runner.cc | 3 | ||||
-rw-r--r-- | content/public/app/content_main.h | 3 |
7 files changed, 93 insertions, 1 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc index 80cd0fb..730f31e 100644 --- a/chrome/app/chrome_main.cc +++ b/chrome/app/chrome_main.cc @@ -10,6 +10,7 @@ #include "base/debug/dump_without_crashing.h" #include "base/win/win_util.h" #include "chrome/common/chrome_constants.h" +#include "chrome/common/terminate_on_heap_corruption_experiment_win.h" #define DLLEXPORT __declspec(dllexport) @@ -49,6 +50,9 @@ int ChromeMain(int argc, const char** argv) { ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName), "DumpProcessWithoutCrash")); base::debug::SetDumpWithoutCrashingFunction(DumpProcess); + + params.enable_termination_on_heap_corruption = + !ShouldExperimentallyDisableTerminateOnHeapCorruption(); #else params.argc = argc; params.argv = argv; diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 0912b3f..502ea68 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -38,6 +38,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/env_vars.h" +#include "chrome/common/terminate_on_heap_corruption_experiment_win.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/install_util.h" @@ -256,6 +257,10 @@ void ChromeBrowserMainPartsWin::PostBrowserStart() { base::TimeDelta::FromSeconds(45)); InitializeChromeElf(); + + // TODO(erikwright): Remove this and the implementation of the experiment by + // September 2014. + InitializeDisableTerminateOnHeapCorruptionExperiment(); } // static diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 225052f..f4b2137 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -177,6 +177,8 @@ 'common/spellcheck_result.h', 'common/switch_utils.cc', 'common/switch_utils.h', + 'common/terminate_on_heap_corruption_experiment_win.cc', + 'common/terminate_on_heap_corruption_experiment_win.h', 'common/tts_messages.h', 'common/tts_utterance_request.cc', 'common/tts_utterance_request.h', diff --git a/chrome/common/terminate_on_heap_corruption_experiment_win.cc b/chrome/common/terminate_on_heap_corruption_experiment_win.cc new file mode 100644 index 0000000..ee27975 --- /dev/null +++ b/chrome/common/terminate_on_heap_corruption_experiment_win.cc @@ -0,0 +1,66 @@ +// Copyright 2014 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 "chrome/common/terminate_on_heap_corruption_experiment_win.h" + +#include "base/command_line.h" +#include "base/metrics/field_trial.h" +#include "base/win/registry.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_version_info.h" + +#if defined(OS_WIN) +#if defined(GOOGLE_CHROME_BUILD) +#define PRODUCT_STRING_PATH L"Google\\Chrome" +#elif defined(CHROMIUM_BUILD) +#define PRODUCT_STRING_PATH L"Chromium" +#else +#error Unknown branding +#endif +#endif // defined(OS_WIN) + +namespace { + +wchar_t* GetBeaconKeyPath() { + chrome::VersionInfo::Channel channel = chrome::VersionInfo::CHANNEL_UNKNOWN; + + // We are called quite early, before the CommandLine is initialized. We don't + // want to permanently initialize it because ContentMainRunner::Initialize + // sets some locale-related stuff to make sure it is parsed properly. But we + // can temporarily initialize it for the purpose of determining if we are + // Canary. + if (!CommandLine::InitializedForCurrentProcess()) { + CommandLine::Init(0, NULL); + channel = chrome::VersionInfo::GetChannel(); + CommandLine::Reset(); + } else { + channel = chrome::VersionInfo::GetChannel(); + } + + if (channel == chrome::VersionInfo::CHANNEL_CANARY) { + return L"SOFTWARE\\" PRODUCT_STRING_PATH + L"\\DisableTerminateOnProcessHeapCorruptionSxs"; + } + return L"SOFTWARE\\" PRODUCT_STRING_PATH + L"\\DisableTerminateOnProcessHeapCorruption"; +} + +} // namespace + +bool ShouldExperimentallyDisableTerminateOnHeapCorruption() { + base::win::RegKey regkey( + HKEY_CURRENT_USER, GetBeaconKeyPath(), KEY_QUERY_VALUE); + return regkey.Valid(); +} + +void InitializeDisableTerminateOnHeapCorruptionExperiment() { + base::win::RegKey regkey(HKEY_CURRENT_USER); + + if (base::FieldTrialList::FindFullName("TerminateOnProcessHeapCorruption") == + "Disabled") { + regkey.CreateKey(GetBeaconKeyPath(), KEY_SET_VALUE); + } else { + regkey.DeleteKey(GetBeaconKeyPath()); + } +} diff --git a/chrome/common/terminate_on_heap_corruption_experiment_win.h b/chrome/common/terminate_on_heap_corruption_experiment_win.h new file mode 100644 index 0000000..aa728c0 --- /dev/null +++ b/chrome/common/terminate_on_heap_corruption_experiment_win.h @@ -0,0 +1,11 @@ +// Copyright 2014 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. + +#ifndef CHROME_COMMON_TERMINATE_ON_HEAP_CORRUPTION_EXPERIMENT_WIN_H_ +#define CHROME_COMMON_TERMINATE_ON_HEAP_CORRUPTION_EXPERIMENT_WIN_H_ + +bool ShouldExperimentallyDisableTerminateOnHeapCorruption(); +void InitializeDisableTerminateOnHeapCorruptionExperiment(); + +#endif // CHROME_COMMON_TERMINATE_ON_HEAP_CORRUPTION_EXPERIMENT_WIN_H_ diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index f8f9a42..81611c5 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -554,7 +554,8 @@ class ContentMainRunnerImpl : public ContentMainRunner { is_initialized_ = true; delegate_ = params.delegate; - base::EnableTerminationOnHeapCorruption(); + if (params.enable_termination_on_heap_corruption) + base::EnableTerminationOnHeapCorruption(); base::EnableTerminationOnOutOfMemory(); // The exit manager is in charge of calling the dtors of singleton objects. diff --git a/content/public/app/content_main.h b/content/public/app/content_main.h index 201fca7..f3ead71 100644 --- a/content/public/app/content_main.h +++ b/content/public/app/content_main.h @@ -25,6 +25,7 @@ class ContentMainDelegate; struct ContentMainParams { explicit ContentMainParams(ContentMainDelegate* delegate) : delegate(delegate), + enable_termination_on_heap_corruption(true), #if defined(OS_WIN) instance(NULL), sandbox_info(NULL), @@ -37,6 +38,8 @@ struct ContentMainParams { ContentMainDelegate* delegate; + bool enable_termination_on_heap_corruption; + #if defined(OS_WIN) HINSTANCE instance; |