Commit 9dce58d3 authored by Matthew Dempsky's avatar Matthew Dempsky

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: default avatarAustin Clements <austin@google.com>
parent e5986209
...@@ -181,7 +181,7 @@ func armcas(ptr *uint32, old, new uint32) bool ...@@ -181,7 +181,7 @@ func armcas(ptr *uint32, old, new uint32) bool
//go:noescape //go:noescape
func Load(addr *uint32) uint32 func Load(addr *uint32) uint32
//go:noescape // NO go:noescape annotation; *addr escapes if result escapes (#31525)
func Loadp(addr unsafe.Pointer) unsafe.Pointer func Loadp(addr unsafe.Pointer) unsafe.Pointer
//go:noescape //go:noescape
......
...@@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32 ...@@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32
//go:noescape //go:noescape
func Load64(ptr *uint64) uint64 func Load64(ptr *uint64) uint64
//go:noescape // NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape //go:noescape
......
...@@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32 ...@@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32
//go:noescape //go:noescape
func Load64(ptr *uint64) uint64 func Load64(ptr *uint64) uint64
//go:noescape // NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape //go:noescape
......
...@@ -116,7 +116,7 @@ func Xchguintptr(ptr *uintptr, new uintptr) uintptr ...@@ -116,7 +116,7 @@ func Xchguintptr(ptr *uintptr, new uintptr) uintptr
//go:noescape //go:noescape
func Load(ptr *uint32) uint32 func Load(ptr *uint32) uint32
//go:noescape // NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape //go:noescape
......
...@@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32 ...@@ -32,7 +32,7 @@ func Load(ptr *uint32) uint32
//go:noescape //go:noescape
func Load64(ptr *uint64) uint64 func Load64(ptr *uint64) uint64
//go:noescape // NO go:noescape annotation; *ptr escapes if result escapes (#31525)
func Loadp(ptr unsafe.Pointer) unsafe.Pointer func Loadp(ptr unsafe.Pointer) unsafe.Pointer
//go:noescape //go:noescape
......
...@@ -13,8 +13,8 @@ import ( ...@@ -13,8 +13,8 @@ import (
"unsafe" "unsafe"
) )
// BAD: should be "leaking param content". // BAD: should always be "leaking param: addr to result ~r1 level=1$".
func Loadp(addr unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr" func Loadp(addr unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr( to result ~r1 level=1)?$"
return atomic.Loadp(addr) return atomic.Loadp(addr)
} }
......
...@@ -13,8 +13,8 @@ import ( ...@@ -13,8 +13,8 @@ import (
"unsafe" "unsafe"
) )
// BAD: should be "leaking param content". // BAD: should be "leaking param: addr to result ~r1 level=1$".
func LoadPointer(addr *unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr" func LoadPointer(addr *unsafe.Pointer) unsafe.Pointer { // ERROR "leaking param: addr$"
return atomic.LoadPointer(addr) return atomic.LoadPointer(addr)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment