1
0
mirror of https://github.com/golang/go synced 2024-11-07 15:06:16 -07:00
go/src/runtime/export_linux_test.go
Cuong Manh Le 2e1a6a28df 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>
2019-10-22 01:03:09 +00:00

20 lines
429 B
Go

// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Export guts for testing.
package runtime
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))
}