]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: do not generate crash dump on Windows 7
authorAlex Brainman <alex.brainman@gmail.com>
Sun, 31 Oct 2021 06:58:34 +0000 (17:58 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Thu, 4 Nov 2021 07:05:31 +0000 (07:05 +0000)
It appears Windows 7 ignores WER_FAULT_REPORTING_NO_UI WerSetFlags
API flag.

And now after CL 307372, runtime will display WER GUI dialogue.

We don't want to introduce random GUI dialogues during Go program
execution. So disable dump crash creation on Windows 7 altogether.

Updates #20498

Change-Id: Ie268a7d4609f8a0eba4fe9ecf250856b0a61b331
Reviewed-on: https://go-review.googlesource.com/c/go/+/360617
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
src/runtime/signal_windows.go

index ca4a9ea451052d41e6ac4d62f09aeb0981442597..b036f3c965bb894f2c9f3acc0892ccb610ac8bf6 100644 (file)
@@ -22,8 +22,16 @@ func disableWER() {
        stdcall1(_SetErrorMode, uintptr(errormode)|SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX)
 }
 
+// isWin7 returns true on Windows 7. Otherwise it returns false.
+//
+//go:nosplit
+func isWin7() bool {
+       var maj, min, build uint32
+       stdcall3(_RtlGetNtVersionNumbers, uintptr(unsafe.Pointer(&maj)), uintptr(unsafe.Pointer(&min)), uintptr(unsafe.Pointer(&build)))
+       return maj < 6 || (maj == 6 && min <= 1)
+}
+
 // enableWERNoUI re-enables Windows error reporting without fault reporting UI.
-// It returns false on older Windows versions (XP and earlier) where WerSetFlags() is not supported.
 //
 // This is marked nosplit since it is used during crash.
 //
@@ -224,9 +232,14 @@ func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) int32 {
 
        _, _, docrash := gotraceback()
        if docrash {
-               // trigger crash dump creation
-               if enableWERNoUI() {
-                       return _EXCEPTION_CONTINUE_SEARCH
+               // Windows 7 apears to ignore WER_FAULT_REPORTING_NO_UI
+               // WerSetFlags API flag. So do not call enableWERNoUI
+               // on Windows 7.
+               if !isWin7() {
+                       // trigger crash dump creation
+                       if enableWERNoUI() {
+                               return _EXCEPTION_CONTINUE_SEARCH
+                       }
                }
        }
        exit(2)