diff options
Diffstat (limited to 'chrome/app')
-rw-r--r-- | chrome/app/chrome_exe_main_gtk.cc | 28 | ||||
-rw-r--r-- | chrome/app/chrome_exe_main_win.cc | 16 | ||||
-rw-r--r-- | chrome/app/chrome_main.cc | 4 | ||||
-rw-r--r-- | chrome/app/chrome_main_posix.cc | 27 | ||||
-rw-r--r-- | chrome/app/chrome_main_win.cc | 30 |
5 files changed, 27 insertions, 78 deletions
diff --git a/chrome/app/chrome_exe_main_gtk.cc b/chrome/app/chrome_exe_main_gtk.cc index 81775b5d..b902e08 100644 --- a/chrome/app/chrome_exe_main_gtk.cc +++ b/chrome/app/chrome_exe_main_gtk.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/process_util.h" #include "build/build_config.h" #include "chrome/browser/first_run/upgrade_util.h" @@ -10,39 +9,12 @@ // windows, this does nothing but load chrome.dll and invoke its entry point in // order to make it easy to update the app from GoogleUpdate. We don't need // that extra layer with on linux. -// -// TODO(tc): This is similar to chrome_exe_main_mac.cc. After it's -// more clear what needs to go here, we should evaluate whether or not -// to merge this file with chrome_exe_main_mac.cc. extern "C" { int ChromeMain(int argc, const char** argv); - -#if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_TCMALLOC) -int tc_set_new_mode(int mode); -#endif } int main(int argc, const char** argv) { - base::EnableTerminationOnHeapCorruption(); - base::EnableTerminationOnOutOfMemory(); - - // NOTE(willchan): One might ask why this call is done here rather than in - // process_util_linux.cc with the definition of - // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a - // dependency on TCMalloc. Really, we ought to have our allocator shim code - // implement this EnableTerminationOnOutOfMemory() function. Whateverz. This - // works for now. -#if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_TCMALLOC) - // For tcmalloc, we need to tell it to behave like new. - tc_set_new_mode(1); -#endif - - // The exit manager is in charge of calling the dtors of singletons. - // Win has one here, but we assert with multiples from BrowserMain() if we - // keep it. - // base::AtExitManager exit_manager; - int return_code = ChromeMain(argc, argv); #if defined(OS_LINUX) && !defined(OS_CHROMEOS) diff --git a/chrome/app/chrome_exe_main_win.cc b/chrome/app/chrome_exe_main_win.cc index f1f54eb..ccb32fb 100644 --- a/chrome/app/chrome_exe_main_win.cc +++ b/chrome/app/chrome_exe_main_win.cc @@ -14,13 +14,7 @@ #include "sandbox/src/dep.h" #include "sandbox/src/sandbox_factory.h" - int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { - base::EnableTerminationOnHeapCorruption(); - - // The exit manager is in charge of calling the dtors of singletons. - base::AtExitManager exit_manager; - bool exit_now = true; // We restarted because of a previous crash. Ask user if we should relaunch. if (ShowRestartDialogIfCrashed(&exit_now)) { @@ -28,9 +22,6 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { return content::RESULT_CODE_NORMAL_EXIT; } - // Initialize the commandline singleton from the environment. - CommandLine::Init(0, NULL); - // Initialize the sandbox services. sandbox::SandboxInterfaceInfo sandbox_info = {0}; sandbox_info.broker_services = sandbox::SandboxFactory::GetBrokerServices(); @@ -41,6 +32,13 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { // Enforces strong DEP support. Vista uses the NXCOMPAT flag in the exe. sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED); } + + // The exit manager is in charge of calling the dtors of singletons. + base::AtExitManager exit_manager; + + // Initialize the commandline singleton from the environment. + CommandLine::Init(0, NULL); + // Load and launch the chrome dll. *Everything* happens inside. MainDllLoader* loader = MakeMainDllLoader(); int rc = loader->Launch(instance, &sandbox_info); diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc index ae0b9af..afe6ad4 100644 --- a/chrome/app/chrome_main.cc +++ b/chrome/app/chrome_main.cc @@ -588,6 +588,10 @@ int ChromeMain(int argc, char** argv) { // There is no HINSTANCE on non-Windows. void* instance = NULL; #endif + + base::EnableTerminationOnHeapCorruption(); + base::EnableTerminationOnOutOfMemory(); + // LowLevelInit performs startup initialization before we // e.g. allocate any memory. It must be the first call on startup. chrome_main::LowLevelInit(instance); diff --git a/chrome/app/chrome_main_posix.cc b/chrome/app/chrome_main_posix.cc index f68a905..8a6262d 100644 --- a/chrome/app/chrome_main_posix.cc +++ b/chrome/app/chrome_main_posix.cc @@ -8,13 +8,18 @@ #include "base/global_descriptors_posix.h" #include "base/logging.h" -#include "base/process_util.h" #include "content/common/chrome_descriptors.h" #if defined(OS_MACOSX) #include "chrome/app/breakpad_mac.h" #endif +#if !defined(OS_MACOSX) && defined(USE_TCMALLOC) +extern "C" { +int tc_set_new_mode(int mode); +} +#endif + namespace { // Setup signal-handling state: resanitize most signals, ignore SIGPIPE. @@ -44,16 +49,16 @@ void SetupSignalHandlers() { namespace chrome_main { void LowLevelInit(void* instance) { -#if defined(OS_MACOSX) - // TODO(mark): Some of these things ought to be handled in - // chrome_exe_main_mac.cc. Under the current architecture, nothing - // in chrome_exe_main can rely directly on chrome_dll code on the - // Mac, though, so until some of this code is refactored to avoid - // such a dependency, it lives here. See also the TODO(mark) - // at InitCrashReporter() and DestructCrashReporter(). - base::EnableTerminationOnHeapCorruption(); - base::EnableTerminationOnOutOfMemory(); -#endif // OS_MACOSX + // NOTE(willchan): One might ask why this call is done here rather than in + // process_util_linux.cc with the definition of + // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a + // dependency on TCMalloc. Really, we ought to have our allocator shim code + // implement this EnableTerminationOnOutOfMemory() function. Whateverz. This + // works for now. +#if !defined(OS_MACOSX) && defined(USE_TCMALLOC) + // For tcmalloc, we need to tell it to behave like new. + tc_set_new_mode(1); +#endif // Set C library locale to make sure CommandLine can parse argument values // in correct encoding. diff --git a/chrome/app/chrome_main_win.cc b/chrome/app/chrome_main_win.cc index bf1e98c..3caff3a 100644 --- a/chrome/app/chrome_main_win.cc +++ b/chrome/app/chrome_main_win.cc @@ -20,10 +20,6 @@ #include "chrome/common/chrome_switches.h" #include "policy/policy_constants.h" -#if defined(USE_TCMALLOC) -#include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" -#endif - namespace { CAppModule _Module; @@ -43,37 +39,11 @@ void PureCall() { _exit(1); } -#pragma warning(push) -// Disables warning 4748 which is: "/GS can not protect parameters and local -// variables from local buffer overrun because optimizations are disabled in -// function." GetStats() will not overflow the passed-in buffer and this -// function never returns. -#pragma warning(disable : 4748) -void OnNoMemory() { -#if defined(USE_TCMALLOC) - // Try to get some information on the stack to make the crash easier to - // diagnose from a minidump, being very careful not to do anything that might - // try to heap allocate. - char buf[32*1024]; - MallocExtension::instance()->GetStats(buf, sizeof(buf)); -#endif - // Kill the process. This is important for security, since WebKit doesn't - // NULL-check many memory allocations. If a malloc fails, returns NULL, and - // the buffer is then used, it provides a handy mapping of memory starting at - // address 0 for an attacker to utilize. - __debugbreak(); - _exit(1); -} -#pragma warning(pop) -#pragma optimize("", on) - // Register the invalid param handler and pure call handler to be able to // notify breakpad when it happens. void RegisterInvalidParamHandler() { _set_invalid_parameter_handler(InvalidParameter); _set_purecall_handler(PureCall); - // Gather allocation failure. - std::set_new_handler(&OnNoMemory); // Also enable the new handler for malloc() based failures. _set_new_mode(1); } |