From ff3af2c1e50a66be0145dc60677599078e4c847c Mon Sep 17 00:00:00 2001 From: "brucedawson@chromium.org" Date: Tue, 22 Mar 2016 20:50:48 +0000 Subject: [PATCH] Enable crash dump collection on builders Toolchain crashes on build machines are an ongoing problem, particularly with the VC++ 2015 migration. Setting this registry key tells Windows Error Reporting to record minidumps (a few MB typically) to a local directory, up to a maximum of ten. This should help with investigations. This change also suppresses Windows Error Reporting dialogs with the DontShowUI registry value, to avoid builder hangs on crashes. See also crrev.com/1816333002 BUG=440500 Review URL: https://codereview.chromium.org/1825163003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299426 0039d316-1c4b-4281-b951-d872f2087c98 --- win_toolchain/get_toolchain_if_necessary.py | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py index dbfb0eb0e..bd44afe5b 100755 --- a/win_toolchain/get_toolchain_if_necessary.py +++ b/win_toolchain/get_toolchain_if_necessary.py @@ -357,6 +357,27 @@ def InstallUniversalCRTIfNeeded(abs_target_dir): return +def EnableCrashDumpCollection(): + """Tell Windows Error Reporting to record crash dumps so that we can diagnose + linker crashes and other toolchain failures. Documented at: + https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181.aspx + """ + if sys.platform == 'win32' and os.environ.get('CHROME_HEADLESS') == '1': + key_name = r'SOFTWARE\Microsoft\Windows\Windows Error Reporting' + try: + key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, key_name) + # Merely creating LocalDumps is sufficient to enable the defaults. + winreg.CreateKey(key, "LocalDumps") + # Disable the WER UI, as documented here: + # https://msdn.microsoft.com/en-us/library/windows/desktop/bb513638.aspx + winreg.SetValueEx(key, "DontShowUI", 0, winreg.REG_DWORD, 1) + # Trap OSError instead of WindowsError so pylint will succeed on Linux. + # Catching errors is important because some build machines are not elevated + # and writing to HKLM requires elevation. + except OSError: + pass + + def main(): parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) parser.add_option('--output-json', metavar='FILE', @@ -471,6 +492,8 @@ def main(): shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), options.output_json) + EnableCrashDumpCollection() + if os.environ.get('GYP_MSVS_VERSION') == '2015': InstallUniversalCRTIfNeeded(abs_toolchain_target_dir)