]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: abort when receiving a signal on a non-Go thread on Windows
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 4 May 2021 16:00:08 +0000 (16:00 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 4 May 2021 21:16:16 +0000 (21:16 +0000)
Currently if a signal lands on a non-Go thread that's handled by the Go
handler, Go will emit a message. However, unlike everywhere else in the
runtime, Go will not abort the process after, and the signal handler
will try to continue executing.

This leads to cascading failures and possibly even memory corruption.

For #45638.

Change-Id: I546f4e82f339d555bed295528d819ac883b92bc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/316809
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/sys_windows_386.s
src/runtime/sys_windows_amd64.s
src/runtime/sys_windows_arm.s
src/runtime/sys_windows_arm64.s

index 64b12859aea6d71492ff66a6b5dc6195595464b0..0b3933502ab3f4f42b8d6e8b2844724bf7a7ab96 100644 (file)
@@ -58,7 +58,9 @@ TEXT  runtime·badsignal2(SB),NOSPLIT,$24
        MOVL    DX, 12(SP)
        MOVL    $0, 16(SP) // overlapped
        CALL    *runtime·_WriteFile(SB)
-       MOVL    BP, SI
+
+       // Does not return.
+       CALL    runtime·abort(SB)
        RET
 
 // faster get/set last error
index e5e2083be2b440b72c689c8eab61b0abae4e2206..e7782846b25c7c3b6f97391bd75c90eeb56adcc8 100644 (file)
@@ -96,6 +96,8 @@ TEXT runtime·badsignal2(SB),NOSPLIT|NOFRAME,$48
        MOVQ    runtime·_WriteFile(SB), AX
        CALL    AX
 
+       // Does not return.
+       CALL    runtime·abort(SB)
        RET
 
 // faster get/set last error
index 189d2f6780d45c63c9bbe180598197044ba11573..48f8c7dedffd5ec8afa7fc22e7156aafc8de5de8 100644 (file)
@@ -97,8 +97,8 @@ TEXT runtime·badsignal2(SB),NOSPLIT|NOFRAME,$0
        MOVW    runtime·_WriteFile(SB), R12
        BL      (R12)
 
-       MOVW    R4, R13                 // restore SP
-       MOVM.IA.W (R13), [R4, R15]      // pop {r4, pc}
+       // Does not return.
+       B       runtime·abort(SB)
 
 TEXT runtime·getlasterror(SB),NOSPLIT,$0
        MRC     15, 0, R0, C13, C0, 2
index 33ac091e1269555314e1682ae8174a89fe906a6a..7a2e11f5ae29832d6536a1fd11a03a2bdff553b2 100644 (file)
@@ -117,7 +117,9 @@ TEXT runtime·badsignal2(SB),NOSPLIT,$16-0
        MOVD    runtime·_WriteFile(SB), R12
        SUB     $16, RSP        // skip over saved frame pointer below RSP
        BL      (R12)
-       ADD     $16, RSP
+
+       // Does not return.
+       B       runtime·abort(SB)
 
        RET