diff options
author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2019-10-19 15:18:34 +0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2019-10-22 01:03:09 +0000 |
commit | 2e1a6a28dfcc57ad6a14c9c27a81ee37b9b6f874 (patch) | |
tree | 8aa1f8ac5ed6db3693353d4cc5242295f6c3ee8d /src/runtime/export_linux_test.go | |
parent | 0050c079d5a50e441aa32d0da5338687890194ef (diff) | |
download | go-2e1a6a28dfcc57ad6a14c9c27a81ee37b9b6f874.tar.gz go-2e1a6a28dfcc57ad6a14c9c27a81ee37b9b6f874.zip |
runtime: fix unsafe.Pointer alignment on Linux
Caught by go test -a -short -gcflags=all=-d=checkptr runtime
TestMincoreErrorSign intentionally uses uintptr(1) to get -EINVAL,
but it violates unsafe pointer rules 2. So use another misaligned
pointer add(new(int32), 1), but do not violate unsafe pointer rules.
TestEpollctlErrorSign passes an unsafe.Pointer of &struct{}{} to
Epollctl, which is then casted to epollevent, causes mis-alignment.
Fixing it by exporting epollevent on runtime_test package, so it can be
passed to Epollctl.
Updates #34972
Change-Id: I78ebfbeaf706fd1d372272af0bbc4e2cabca4631
Reviewed-on: https://go-review.googlesource.com/c/go/+/202157
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/export_linux_test.go')
-rw-r--r-- | src/runtime/export_linux_test.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/export_linux_test.go b/src/runtime/export_linux_test.go index c73f2f33d1..b7c901f238 100644 --- a/src/runtime/export_linux_test.go +++ b/src/runtime/export_linux_test.go @@ -10,6 +10,9 @@ import "unsafe" var NewOSProc0 = newosproc0 var Mincore = mincore +var Add = add + +type EpollEvent epollevent func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 { return epollctl(epfd, op, fd, (*epollevent)(ev)) |