]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make sure to properly park before going to sleep in Windows ConsoleControlHa...
authorPatrik Nyblom <pnyb@google.com>
Tue, 16 Nov 2021 22:35:59 +0000 (14:35 -0800)
committerPatrik Nyblom <pnyb@google.com>
Wed, 17 Nov 2021 17:04:16 +0000 (17:04 +0000)
This change avoids the program intermittently hanging on windows/arm64 after getting
a signal for which the ConsoleControlHandler can not return.

Fixes #49458

Change-Id: Ie28f0f437c7e0f9634b6b3e29dc6cdebd5d996f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/364556
Trust: Patrik Nyblom <pnyb@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/runtime/os_windows.go

index 648239fb366a15b6f96d53af2cb76e3867ebc871..7ffb3a11b5e748ac26809635ac080c4365a00680 100644 (file)
@@ -1194,8 +1194,10 @@ func ctrlHandler(_type uint32) uintptr {
        if sigsend(s) {
                if s == _SIGTERM {
                        // Windows terminates the process after this handler returns.
-                       // Block indefinitely to give signal handlers a chance to clean up.
-                       stdcall1(_Sleep, uintptr(_INFINITE))
+                       // Block indefinitely to give signal handlers a chance to clean up,
+                       // but make sure to be properly parked first, so the rest of the
+                       // program can continue executing.
+                       block()
                }
                return 1
        }