0

Signal chrome_elf to initialize crash reporting, rather than doing it in DllMain

Currently, initialization crash reporting indirectly calls
CreateProcess() from chrome_elf's DllMain(), which causes deadlock in
some configurations (showing up in M54).

Instead, signal to chrome_elf that it should initialize crash reporting
later in WinMain(). This means we lose a little coverage that we were
hoping to gain from the move to chrome_elf, but a localized fix is
required for merge to stable.

Follow up bug is https://crbug.com/656800.

BUG=655788, 656800
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win10_chromium_x64_rel_ng
TEST=enforce certificate rules per https://bugs.chromium.org/p/chromium/issues/detail?id=655788#c57 and then try to launch chrome.

Review-Url: https://codereview.chromium.org/2428703002
Cr-Commit-Position: refs/heads/master@{#425840}
This commit is contained in:
scottmg
2016-10-17 18:01:21 -07:00
committed by Commit bot
parent 97bc39eade
commit f3a5670dd8
4 changed files with 15 additions and 5 deletions

@ -204,6 +204,8 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
int main() {
HINSTANCE instance = GetModuleHandle(nullptr);
#endif
SignalInitializeCrashReporting();
// Initialize the CommandLine singleton from the environment.
base::CommandLine::Init(0, nullptr);
const base::CommandLine* command_line =

@ -7,6 +7,7 @@ LIBRARY "chrome_elf.dll"
EXPORTS
IsBlacklistInitialized
SignalChromeElf
SignalInitializeCrashReporting
SuccessfullyBlocked
GetBlacklistIndex
AddDllToBlacklist

@ -11,17 +11,23 @@
#include "chrome_elf/blacklist/blacklist.h"
#include "chrome_elf/crash/crash_helper.h"
// This function is a temporary workaround for https://crbug.com/655788. We
// need to come up with a better way to initialize crash reporting that can
// happen inside DllMain().
void SignalInitializeCrashReporting() {
if (!elf_crash::InitializeCrashReporting()) {
#ifdef _DEBUG
assert(false);
#endif // _DEBUG
}
}
void SignalChromeElf() {
blacklist::ResetBeacon();
}
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
if (reason == DLL_PROCESS_ATTACH) {
if (!elf_crash::InitializeCrashReporting()) {
#ifdef _DEBUG
assert(false);
#endif // _DEBUG
}
// CRT on initialization installs an exception filter which calls
// TerminateProcess. We need to hook CRT's attempt to set an exception.
// NOTE: Do not hook if ASan is present, or ASan will fail to install

@ -5,6 +5,7 @@
#ifndef CHROME_ELF_CHROME_ELF_MAIN_H_
#define CHROME_ELF_CHROME_ELF_MAIN_H_
extern "C" void SignalInitializeCrashReporting();
extern "C" void SignalChromeElf();
#endif // CHROME_ELF_CHROME_ELF_MAIN_H_