]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Prevent Cygwin from concealing non-abort() crashes
authorMichał Kępień <michal@isc.org>
Thu, 26 Sep 2019 08:34:01 +0000 (10:34 +0200)
committerMichał Kępień <michal@isc.org>
Thu, 26 Sep 2019 08:34:01 +0000 (10:34 +0200)
BIND system tests are run in a Cygwin environment.  Apparently Cygwin
shell sets the SEM_NOGPFAULTERRORBOX bit in its process error mode which
is then inherited by all spawned child processes.  This bit prevents the
Windows Error Reporting dialog from being displayed, which I assume is
part of an effort to contain memory handling errors triggered by Cygwin
binaries in the Cygwin environment.  Unfortunately, this also prevents
automatic crash dump creation by Windows Error Reporting and Cygwin
itself does not handle memory errors in native Windows processes spawned
from a Cygwin shell.

Fix by clearing the SEM_NOGPFAULTERRORBOX bit inside named if it is
started in a Cygwin environment, thus overriding the Cygwin-set process
error mode in order to enable Windows Error Reporting to handle all
named crashes.

bin/named/win32/os.c

index ec6da58c94e0d1d20043816c912b9c521fca06c9..2bed9223104c115b218d38c4489e02b476578dd3 100644 (file)
@@ -109,6 +109,16 @@ named_os_init(const char *progname) {
         * ntservice_init();
         */
        version_check(progname);
+       /*
+        * If running in a Cygwin environment, clear the SEM_NOGPFAULTERRORBOX
+        * bit in the process error mode to prevent Cygwin from concealing
+        * non-abort() crashes, giving Windows Error Reporting a chance to
+        * handle such crashes.  This is done to ensure all crashes triggered
+        * by system tests can be detected.
+        */
+       if (getenv("CYGWIN") != NULL) {
+               SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX);
+       }
 }
 
 void