From 4ea8b4291afc676e71713970186da5e112918a0e Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Fri, 9 Sep 2022 14:52:00 -0700
Subject: [PATCH v13 09/20] ci: windows: set error mode to not include
 SEM_NOGPFAULTERRORBOX

This allows crashdumps to work and fixes an odd python crash.

Discussion: https://postgr.es/m/20220909235836.lz3igxtkcjb5w7zb%40awork3.anarazel.de
---
 .cirrus.yml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/.cirrus.yml b/.cirrus.yml
index 81eb8a9996d..7034352c487 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -386,6 +386,15 @@ task:
     # currently have a tool for that...
     CIRRUS_ESCAPING_PROCESSES: 1
 
+    # Cirrus defaults to SetErrorMode(SEM_NOGPFAULTERRORBOX | ...). That
+    # prevents crash reporting from working unless binaries do SetErrorMode()
+    # themselves. Furthermore, it appears that either python or, more likely,
+    # the C runtime has a bug where SEM_NOGPFAULTERRORBOX can very
+    # occasionally *trigger* a crash on process exit - which is hard to debug,
+    # given that it explicitly prevents crash dumps from working...
+    # 0x8001 is SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX
+    CIRRUS_WINDOWS_ERROR_MODE: 0x8001
+
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*'
 
   windows_container:
@@ -398,6 +407,7 @@ task:
     systeminfo
     powershell -Command get-psdrive -psprovider filesystem
     set
+    python -c "import msvcrt; print(hex(msvcrt.GetErrorMode()))"
 
   setup_additional_packages_script: |
     REM choco install -y --no-progress ...
-- 
2.37.3.542.gdd3f6c4cae

