1
0
mirror of https://github.com/golang/go synced 2024-07-01 07:56:09 +00:00

runtime/internal/atomic: remove bad go:noescape annotations on Loadp

The //go:noescape directive says that arguments don't leak at all,
which is too aggressive of a claim for functions that return pointers
derived from their parameters.

Remove the directive for now. Long term fix will require a new
directive that allows more fine-grained control over escape analysis
information supplied for functions implemented in assembly.

Also, update the BAD comments in the test cases for Loadp: we really
want that *ptr leaks to the result parameter, not that *ptr leaks to
the heap.

Updates #31525.

Change-Id: Ibfa61f2b70daa7ed3223056b57eeee777eef2e31
Reviewed-on: https://go-review.googlesource.com/c/go/+/172578
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Matthew Dempsky 2019-04-17 11:23:53 -07:00
parent e5986209e0
commit 9dce58d30d
7 changed files with 9 additions and 9 deletions

View File

@ -181,7 +181,7 @@ func armcas(ptr *uint32, old, new uint32) bool
//go:noescape
func Load(addr *uint32) uint32
//go:noescape
// NO go:noescape annotation; *addr escapes if result escapes (#31525)
func Loadp(addr unsafe.Pointer) unsafe.Pointer
//go:noescape

View File

@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32
//go:noescape
func Load64(ptr *uint64) uint64
//go:noescape
// NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape

View File

@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32
//go:noescape
func Load64(ptr *uint64) uint64
//go:noescape
// NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape

View File

@ -116,7 +116,7 @@ func Xchguintptr(ptr *uintptr, new uintptr) uintptr
//go:noescape
func Load(ptr *uint32) uint32
//go:noescape
// NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape

View File

@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32
//go:noescape
func Load64(ptr *uint64) uint64
//go:noescape
// NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape

View File

@ -13,8 +13,8 @@ import (
"unsafe"
)
// BAD: should be "leaking param content".
func Loadp(addr unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr"
// BAD: should always be "leaking param: addr to result ~r1 level=1$".
func Loadp(addr unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr( to result ~r1 level=1)?$"
return atomic.Loadp(addr)
}

View File

@ -13,8 +13,8 @@ import (
"unsafe"
)
// BAD: should be "leaking param content".
func LoadPointer(addr *unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr"
// BAD: should be "leaking param: addr to result ~r1 level=1$".
func LoadPointer(addr *unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr$"
return atomic.LoadPointer(addr)
}