go/src/strings
Matthew Dempsky 80a6fedea0 cmd/compile: add -d=checkptr to validate unsafe.Pointer rules
This CL adds -d=checkptr as a compile-time option for adding
instrumentation to check that Go code is following unsafe.Pointer
safety rules dynamically. In particular, it currently checks two
things:

1. When converting unsafe.Pointer to *T, make sure the resulting
pointer is aligned appropriately for T.

2. When performing pointer arithmetic, if the result points to a Go
heap object, make sure we can find an unsafe.Pointer-typed operand
that pointed into the same object.

These checks are currently disabled for the runtime, and can also be
disabled through a new //go:nocheckptr annotation. The latter is
necessary for functions like strings.noescape, which intentionally
violate safety rules to workaround escape analysis limitations.

Fixes #22218.

Change-Id: If5a51273881d93048f74bcff10a3275c9c91da6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/162237
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-10-17 00:40:21 +00:00
..
builder.go cmd/compile: add -d=checkptr to validate unsafe.Pointer rules 2019-10-17 00:40:21 +00:00
builder_test.go
compare.go
compare_test.go strings: lower running time of TestCompareStrings 2018-11-04 18:55:55 +00:00
example_test.go strings: clarify usage of Title and ToTitle 2019-07-30 02:52:57 +00:00
export_test.go
reader.go bytes, strings: fix Reader.UnreadRune returning without error on a zero Reader 2018-10-29 20:07:25 +00:00
reader_test.go bytes, strings: fix Reader.UnreadRune returning without error on a zero Reader 2018-10-29 20:07:25 +00:00
replace.go strings: document that order of pairs matters in NewReplacer 2019-07-10 21:26:21 +00:00
replace_test.go
search.go
search_test.go
strings.go strings, bytes: clarify usage of EqualFolds 2019-09-21 21:45:58 +00:00
strings_test.go cmd/gofmt: fix computation of function header size 2019-09-24 16:36:56 +00:00