aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2021-05-06 12:24:20 -0400
committerCherry Mui <cherryyz@google.com>2021-05-06 20:30:00 +0000
commit4dbad795100bc0f5f9419bbb44b1ff0beb60a88c (patch)
tree3b8a718ee08aab9d398b596145a10d05e71a28fc /src/runtime
parentf39997b2bebd54416bfb437fa1484fd8a5f43abb (diff)
downloadgo-4dbad795100bc0f5f9419bbb44b1ff0beb60a88c.tar.gz
go-4dbad795100bc0f5f9419bbb44b1ff0beb60a88c.zip
runtime: call unlockOSThread directly in Windows syscall functions
Windows syscall functions (e.g. syscall.Syscall9) are defined as cgo_unsafe_args (because it takes the address of one argument and use that to access all arguments) which makes them ABI0. In some case we may need ABI wrappers for them. Because those functions have a large number of arguments, the wrapper can take a non-trivial amount of stack frame, causing nosplit overflow when inlining is disabled. The overflow call chain involves deferreturn. This CL changes a deferred call to unlockOSThread to a direct call. If the syscall functions panics, it is likely a fatal error anyway. Fixes #45698. Change-Id: I280be826644de1205f9c8f5efaa4ec5e1b4eebc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/316650 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/syscall_windows.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/syscall_windows.go b/src/runtime/syscall_windows.go
index 6521bb2c41..6b9195bcd5 100644
--- a/src/runtime/syscall_windows.go
+++ b/src/runtime/syscall_windows.go
@@ -482,12 +482,12 @@ func syscall_Syscall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err ui
//go:cgo_unsafe_args
func syscall_Syscall9(fn, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr) {
lockOSThread()
- defer unlockOSThread()
c := &getg().m.syscall
c.fn = fn
c.n = nargs
c.args = uintptr(noescape(unsafe.Pointer(&a1)))
cgocall(asmstdcallAddr, unsafe.Pointer(c))
+ unlockOSThread()
return c.r1, c.r2, c.err
}
@@ -496,12 +496,12 @@ func syscall_Syscall9(fn, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1
//go:cgo_unsafe_args
func syscall_Syscall12(fn, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 uintptr) (r1, r2, err uintptr) {
lockOSThread()
- defer unlockOSThread()
c := &getg().m.syscall
c.fn = fn
c.n = nargs
c.args = uintptr(noescape(unsafe.Pointer(&a1)))
cgocall(asmstdcallAddr, unsafe.Pointer(c))
+ unlockOSThread()
return c.r1, c.r2, c.err
}
@@ -510,12 +510,12 @@ func syscall_Syscall12(fn, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
//go:cgo_unsafe_args
func syscall_Syscall15(fn, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) {
lockOSThread()
- defer unlockOSThread()
c := &getg().m.syscall
c.fn = fn
c.n = nargs
c.args = uintptr(noescape(unsafe.Pointer(&a1)))
cgocall(asmstdcallAddr, unsafe.Pointer(c))
+ unlockOSThread()
return c.r1, c.r2, c.err
}
@@ -524,11 +524,11 @@ func syscall_Syscall15(fn, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
//go:cgo_unsafe_args
func syscall_Syscall18(fn, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18 uintptr) (r1, r2, err uintptr) {
lockOSThread()
- defer unlockOSThread()
c := &getg().m.syscall
c.fn = fn
c.n = nargs
c.args = uintptr(noescape(unsafe.Pointer(&a1)))
cgocall(asmstdcallAddr, unsafe.Pointer(c))
+ unlockOSThread()
return c.r1, c.r2, c.err
}