Skip to content

Commit 7b5a344

Browse files
committed
runtime: remove unused badsignal2 on windows
This CL removes badsignal2 function, as it is unused on Windows. badsignal2 was originally intended to abort the process when an exception was raised on a non-Go thread, following the same approach as Linux and others. Since it was added, back on https://golang.org/cl/5797068, it has caused several issues on Windows, see #8224 and #50877. That's because we can't know wether the signal is bad or not, as our trap might not be at the end of the exception handler chain. To fix those issues, https://golang.org/cl/104200046 and CL 442896 stopped calling badsignal2, and CL 458135 removed one last incorrect call on amd64 and 386. Change-Id: I5bd31ee2672118ae0f1a2c8b46a1bb0f4893a011 Reviewed-on: https://go-review.googlesource.com/c/go/+/463116 Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Quim Muntal <[email protected]> Reviewed-by: Alex Brainman <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent cf9263d commit 7b5a344

File tree

6 files changed

+0
-117
lines changed

6 files changed

+0
-117
lines changed

src/runtime/os_windows.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,6 @@ func initLongPathSupport() {
546546
func osinit() {
547547
asmstdcallAddr = unsafe.Pointer(abi.FuncPCABI0(asmstdcall))
548548

549-
setBadSignalMsg()
550-
551549
loadOptionalSyscalls()
552550

553551
disableWER()

src/runtime/signal_windows.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,6 @@ func sigpanic() {
375375
throw("fault")
376376
}
377377

378-
var (
379-
badsignalmsg [100]byte
380-
badsignallen int32
381-
)
382-
383-
func setBadSignalMsg() {
384-
const msg = "runtime: signal received on thread not created by Go.\n"
385-
for i, c := range msg {
386-
badsignalmsg[i] = byte(c)
387-
badsignallen++
388-
}
389-
}
390-
391378
// Following are not implemented.
392379

393380
func initsig(preinit bool) {
@@ -402,12 +389,6 @@ func sigdisable(sig uint32) {
402389
func sigignore(sig uint32) {
403390
}
404391

405-
func badsignal2()
406-
407-
func raisebadsignal(sig uint32) {
408-
badsignal2()
409-
}
410-
411392
func signame(sig uint32) string {
412393
return ""
413394
}

src/runtime/sys_windows_386.s

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,6 @@ TEXT runtime·asmstdcall(SB),NOSPLIT,$0
4444

4545
RET
4646

47-
TEXT runtime·badsignal2(SB),NOSPLIT,$24
48-
// stderr
49-
MOVL $-12, 0(SP)
50-
MOVL SP, BP
51-
CALL *runtime·_GetStdHandle(SB)
52-
MOVL BP, SP
53-
54-
MOVL AX, 0(SP) // handle
55-
MOVL $runtime·badsignalmsg(SB), DX // pointer
56-
MOVL DX, 4(SP)
57-
MOVL runtime·badsignallen(SB), DX // count
58-
MOVL DX, 8(SP)
59-
LEAL 20(SP), DX // written count
60-
MOVL $0, 0(DX)
61-
MOVL DX, 12(SP)
62-
MOVL $0, 16(SP) // overlapped
63-
CALL *runtime·_WriteFile(SB)
64-
65-
// Does not return.
66-
CALL runtime·abort(SB)
67-
RET
68-
6947
// faster get/set last error
7048
TEXT runtime·getlasterror(SB),NOSPLIT,$0
7149
MOVL 0x34(FS), AX

src/runtime/sys_windows_amd64.s

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,6 @@ loadregs:
7575

7676
RET
7777

78-
TEXT runtime·badsignal2(SB),NOSPLIT|NOFRAME,$48
79-
// stderr
80-
MOVQ $-12, CX // stderr
81-
MOVQ CX, 0(SP)
82-
MOVQ runtime·_GetStdHandle(SB), AX
83-
CALL AX
84-
85-
MOVQ AX, CX // handle
86-
MOVQ CX, 0(SP)
87-
MOVQ $runtime·badsignalmsg(SB), DX // pointer
88-
MOVQ DX, 8(SP)
89-
MOVL $runtime·badsignallen(SB), R8 // count
90-
MOVQ R8, 16(SP)
91-
LEAQ 40(SP), R9 // written count
92-
MOVQ $0, 0(R9)
93-
MOVQ R9, 24(SP)
94-
MOVQ $0, 32(SP) // overlapped
95-
MOVQ runtime·_WriteFile(SB), AX
96-
CALL AX
97-
98-
// Does not return.
99-
CALL runtime·abort(SB)
100-
RET
101-
10278
// faster get/set last error
10379
TEXT runtime·getlasterror(SB),NOSPLIT,$0
10480
MOVQ 0x30(GS), AX

src/runtime/sys_windows_arm.s

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,6 @@ loadregs:
7676

7777
MOVM.IA.W (R13), [R4, R5, R15]
7878

79-
TEXT runtime·badsignal2(SB),NOSPLIT|NOFRAME,$0
80-
MOVM.DB.W [R4, R14], (R13) // push {r4, lr}
81-
MOVW R13, R4 // save original stack pointer
82-
SUB $8, R13 // space for 2 variables
83-
BIC $0x7, R13 // alignment for ABI
84-
85-
// stderr
86-
MOVW runtime·_GetStdHandle(SB), R1
87-
MOVW $-12, R0
88-
BL (R1)
89-
90-
MOVW $runtime·badsignalmsg(SB), R1 // lpBuffer
91-
MOVW $runtime·badsignallen(SB), R2 // lpNumberOfBytesToWrite
92-
MOVW (R2), R2
93-
ADD $0x4, R13, R3 // lpNumberOfBytesWritten
94-
MOVW $0, R12 // lpOverlapped
95-
MOVW R12, (R13)
96-
97-
MOVW runtime·_WriteFile(SB), R12
98-
BL (R12)
99-
100-
// Does not return.
101-
B runtime·abort(SB)
102-
10379
TEXT runtime·getlasterror(SB),NOSPLIT,$0
10480
MRC 15, 0, R0, C13, C0, 2
10581
MOVW 0x34(R0), R0

src/runtime/sys_windows_arm64.s

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,6 @@ _0args:
9999
LDP.P 32(RSP), (R29, R30)
100100
RET
101101

102-
TEXT runtime·badsignal2(SB),NOSPLIT,$16-0
103-
NO_LOCAL_POINTERS
104-
105-
// stderr
106-
MOVD runtime·_GetStdHandle(SB), R1
107-
MOVD $-12, R0
108-
SUB $16, RSP // skip over saved frame pointer below RSP
109-
BL (R1)
110-
ADD $16, RSP
111-
112-
// handle in R0 already
113-
MOVD $runtime·badsignalmsg(SB), R1 // lpBuffer
114-
MOVD $runtime·badsignallen(SB), R2 // lpNumberOfBytesToWrite
115-
MOVD (R2), R2
116-
// point R3 to stack local that will receive number of bytes written
117-
ADD $16, RSP, R3 // lpNumberOfBytesWritten
118-
MOVD $0, R4 // lpOverlapped
119-
MOVD runtime·_WriteFile(SB), R12
120-
SUB $16, RSP // skip over saved frame pointer below RSP
121-
BL (R12)
122-
123-
// Does not return.
124-
B runtime·abort(SB)
125-
126-
RET
127-
128102
TEXT runtime·getlasterror(SB),NOSPLIT|NOFRAME,$0
129103
MOVD TEB_error(R18_PLATFORM), R0
130104
MOVD R0, ret+0(FP)

0 commit comments

Comments
 (0)