diff options
| author | Alan Donovan <adonovan@google.com> | 2025-05-19 13:05:24 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-05-19 10:38:56 -0700 |
| commit | a74ae952826fd65006a8190c50bbbee4c4869cf9 (patch) | |
| tree | 0d432209deb07d0da92cd642e53adbb3b1e515d6 /src/strings | |
| parent | bd299852121f997b8bff3c9de244df27427819f3 (diff) | |
| download | go-a74ae952826fd65006a8190c50bbbee4c4869cf9.tar.xz | |
strings,bytes: add internal docs about perennial noCopy questions
Updates #26462
Updates #25907
Updates #47276
Updates #48398
Change-Id: Ic64fc8d0c284f6e5aa383a8d417fa5768dcd7925
Reviewed-on: https://go-review.googlesource.com/c/go/+/674096
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/strings')
| -rw-r--r-- | src/strings/builder.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/strings/builder.go b/src/strings/builder.go index e6df08c6f4..7ecef3176b 100644 --- a/src/strings/builder.go +++ b/src/strings/builder.go @@ -23,6 +23,12 @@ type Builder struct { buf []byte } +// copyCheck implements a dynamic check to prevent modification after +// copying a non-zero Builder, which would be unsafe (see #25907, #47276). +// +// We cannot add a noCopy field to Builder, to cause vet's copylocks +// check to report copying, because copylocks cannot reliably +// discriminate the zero and nonzero cases. func (b *Builder) copyCheck() { if b.addr == nil { // This hack works around a failing of Go's escape analysis |
