From a2b8c250a8f7f8ab6f64ccb69d9dc613b02d5da3 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 27 Apr 2017 13:02:21 -0400 Subject: [PATCH] Windows: Revert early chrome_elf crashpad initialization (issue #2122) --- libcef/browser/browser_main.cc | 5 ----- libcef/browser/context.cc | 26 ++++++++++++++++++++++---- libcef/common/crash_reporting_win.cc | 15 --------------- libcef/common/crash_reporting_win.h | 4 ---- patch/patches/crashpad_1995.patch | 4 ++-- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/libcef/browser/browser_main.cc b/libcef/browser/browser_main.cc index 07cd86307..05d12bf2a 100644 --- a/libcef/browser/browser_main.cc +++ b/libcef/browser/browser_main.cc @@ -48,7 +48,6 @@ #include "ui/wm/core/wm_state.h" #if defined(OS_WIN) -#include "libcef/common/crash_reporting_win.h" #include "ui/base/cursor/cursor_loader_win.h" #endif #endif // defined(USE_AURA) @@ -172,10 +171,6 @@ int CefBrowserMainParts::PreCreateThreads() { } void CefBrowserMainParts::PreMainMessageLoopRun() { -#if defined(OS_WIN) - crash_reporting_win::BlockUntilHandlerStarted(); -#endif - if (extensions::ExtensionsEnabled()) { // Initialize extension global objects before creating the global // BrowserContext. diff --git a/libcef/browser/context.cc b/libcef/browser/context.cc index fd813dbed..e419d0401 100644 --- a/libcef/browser/context.cc +++ b/libcef/browser/context.cc @@ -60,7 +60,8 @@ class CefForceShutdown { } } g_force_shutdown; -#if defined(OS_WIN) && defined(ARCH_CPU_X86_64) +#if defined(OS_WIN) +#if defined(ARCH_CPU_X86_64) // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness // of them at the OS level (this is fixed in VS2015). We force off usage of // FMA3 instructions in the CRT to avoid using that path and hitting illegal @@ -72,7 +73,18 @@ void DisableFMA3() { disabled = true; _set_FMA3_enable(0); } -#endif +#endif // defined(ARCH_CPU_X86_64) + +// Signal chrome_elf to initialize crash reporting, rather than doing it in +// DllMain. See https://crbug.com/656800 for details. +void InitCrashReporter() { + static bool initialized = false; + if (initialized) + return; + initialized = true; + SignalInitializeCrashReporting(); +} +#endif // defined(OS_WIN) #if defined(OS_MACOSX) || defined(OS_WIN) @@ -143,9 +155,12 @@ bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) { int CefExecuteProcess(const CefMainArgs& args, CefRefPtr application, void* windows_sandbox_info) { -#if defined(OS_WIN) && defined(ARCH_CPU_X86_64) +#if defined(OS_WIN) +#if defined(ARCH_CPU_X86_64) DisableFMA3(); #endif + InitCrashReporter(); +#endif base::CommandLine command_line(base::CommandLine::NO_PROGRAM); #if defined(OS_WIN) @@ -199,9 +214,12 @@ bool CefInitialize(const CefMainArgs& args, const CefSettings& settings, CefRefPtr application, void* windows_sandbox_info) { -#if defined(OS_WIN) && defined(ARCH_CPU_X86_64) +#if defined(OS_WIN) +#if defined(ARCH_CPU_X86_64) DisableFMA3(); #endif + InitCrashReporter(); +#endif // Return true if the global context already exists. if (g_context) diff --git a/libcef/common/crash_reporting_win.cc b/libcef/common/crash_reporting_win.cc index 6d319c146..aa74c76ef 100644 --- a/libcef/common/crash_reporting_win.cc +++ b/libcef/common/crash_reporting_win.cc @@ -6,8 +6,6 @@ #include "libcef/common/crash_reporting_win.h" -#include "libcef/common/crash_reporting.h" - #include "base/debug/crash_logging.h" #include "base/strings/utf_string_conversions.h" #include "chrome/common/chrome_constants.h" @@ -119,17 +117,4 @@ bool InitializeCrashReportingForModule() { return false; } -void BlockUntilHandlerStarted() { - if (!crash_reporting::Enabled()) - return; - - HMODULE chrome_elf = GetModuleHandle(chrome::kChromeElfDllName); - if (chrome_elf) { - auto block_until_handler_started = reinterpret_cast( - GetProcAddress(chrome_elf, "BlockUntilHandlerStartedImpl")); - if (block_until_handler_started) - block_until_handler_started(); - } -} - } // namespace crash_reporting_win diff --git a/libcef/common/crash_reporting_win.h b/libcef/common/crash_reporting_win.h index f08f87164..28c43dad8 100644 --- a/libcef/common/crash_reporting_win.h +++ b/libcef/common/crash_reporting_win.h @@ -8,8 +8,4 @@ namespace crash_reporting_win { // state from chrome_elf via exported functions. bool InitializeCrashReportingForModule(); -// Called from libcef early in main process startup to ensure that the crash -// handler process is started before other sub-processes are created. -void BlockUntilHandlerStarted(); - } // namespace crash_reporting_win diff --git a/patch/patches/crashpad_1995.patch b/patch/patches/crashpad_1995.patch index a699fcaa3..3d5b0e91c 100644 --- a/patch/patches/crashpad_1995.patch +++ b/patch/patches/crashpad_1995.patch @@ -557,10 +557,10 @@ index 94a350f..61667a8 100644 (*annotations)["special"] = base::UTF16ToUTF8(special_build); #if defined(ARCH_CPU_X86) - (*annotations)["plat"] = std::string("Win32"); -+ (*annotations)["platform"] = std::string("Win32"); ++ (*annotations)["platform"] = std::string("win32"); #elif defined(ARCH_CPU_X86_64) - (*annotations)["plat"] = std::string("Win64"); -+ (*annotations)["platform"] = std::string("Win64"); ++ (*annotations)["platform"] = std::string("win64"); #endif }