diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-11-27 00:42:41 -0500 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-11-30 22:14:36 +0000 |
commit | 7f688d18c0ae6df3e895d21799b8ece7d5941293 (patch) | |
tree | 3dc79202b2267040ee7f7d6fea933466ade45986 /src/runtime/sys_darwin.go | |
parent | d2b436d95d99cb3ff587bf0d2e893a8d027f8292 (diff) | |
download | go-7f688d18c0ae6df3e895d21799b8ece7d5941293.tar.gz go-7f688d18c0ae6df3e895d21799b8ece7d5941293.zip |
runtime: mlock signal stack on macOS/ARM64
Apparently, the macOS ARM64 kernel has a bug where when a signal
arrives and the signal stack is not currently faulted in, it may
kill the program with a SIGILL. Work around it by mlock the
signal stacks.
Fixes #42774.
Change-Id: I99a4b3fdb6d8af1c945725ddc2c25568d81c510a
Reviewed-on: https://go-review.googlesource.com/c/go/+/273686
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/runtime/sys_darwin.go')
-rw-r--r-- | src/runtime/sys_darwin.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go index a7983be2ef..c63ba8c6cd 100644 --- a/src/runtime/sys_darwin.go +++ b/src/runtime/sys_darwin.go @@ -228,6 +228,13 @@ func madvise_trampoline() //go:nosplit //go:cgo_unsafe_args +func mlock(addr unsafe.Pointer, n uintptr) { + libcCall(unsafe.Pointer(funcPC(mlock_trampoline)), unsafe.Pointer(&addr)) +} +func mlock_trampoline() + +//go:nosplit +//go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(funcPC(read_trampoline)), unsafe.Pointer(&fd)) } @@ -465,6 +472,7 @@ func setNonblock(fd int32) { //go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_error __error "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_usleep usleep "/usr/lib/libSystem.B.dylib" |