pgsql: windows: Improve crash / assert / exception handling.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: windows: Improve crash / assert / exception handling.
Date: 2022-02-03 02:36:53
Message-ID: E1nFRzR-0000Iq-Kv@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

windows: Improve crash / assert / exception handling.

startup_hacks() called SetErrorMode() with the SEM_NOGPFAULTERRORBOX argument
to prevent GUI popups on error. While that likely was sufficient at some
point, there are other sources of error popups.

At the same time SEM_NOGPFAULTERRORBOX unfortunately also prevents
"just-in-time debuggers" from working reliably, i.e. the ability to attach to
a process on crash. This prevents collecting crash dumps as part of CI.

The error popups are particularly problematic when they occur during automated
testing, as they can cause the tests to hang, waiting for a button to be
clicked.

This commit improves the error handling setup in startup_hacks() to address
those problems. SEM_NOGPFAULTERRORBOX is not used anymore, instead various
other APIs are used to disable popups and to redirect output to stderr where
possible.

While this improves the situation for postgres.exe, it doesn't address similar
issues in all the other executables. There currently is no codepath that's
called early on for all frontend programs.

I've tested that this prevents GUI popups and allows JIT debugging in case of
crashes due to:
- abort()
- assert()
- C runtime errors
- unhandled exceptions
both in debug and non-debug mode, on Win10 with MSVC 2019 and with MinGW.

Now that crash reports are generated on windows, collect them in windows CI.

Discussion: https://postgr.es/m/20211005193033.tg4pqswgvu3hcolm@alap3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f3feff825940972c0dcf1173f0a6a4ff43f8d382

Modified Files
--------------
.cirrus.yml | 6 +++++-
src/backend/main/main.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 58 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2022-02-03 02:54:17 pgsql: doc: clarify syntax notation, particularly parentheses
Previous Message Andres Freund 2022-02-03 01:32:16 pgsql: ci: windows: run tests under timeout.