]> Cypherpunks repositories - gostls13.git/commit
runtime: avoid unsafe.{Slice,String} in debuglog
authorMichael Pratt <mpratt@google.com>
Mon, 17 Oct 2022 19:57:48 +0000 (15:57 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 18 Oct 2022 16:59:26 +0000 (16:59 +0000)
commitc45ebef05edcb217be8f9bf1d7649763132727cc
tree572e1c2658e3ff2283407236931a3c8e82c60882
parent7cf06f070e56dfb6507122704bc75d697ccc350f
runtime: avoid unsafe.{Slice,String} in debuglog

CL 428157 and CL 428759 switched debuglog to using unsafe.String and
unsafe.Slice, which broke the build with -tags=debuglog because this is
a no write barrier context, but runtime.unsafeString and unsafeSlice can
panic, which includes write barriers.

We could add a panicCheck1 path to these functions to reallow write
barriers, but it is a big mess to pass around the caller PC,
particularly since the compiler generates calls. It is much simpler to
just avoid unsafe.String and Slice.

Also add a basic test to build the runtime with -tags=debuglog to help
avoid future regressions.

For #54854.

Change-Id: I702418b986fbf189664e9aa4f40bc7de4d9e7781
Reviewed-on: https://go-review.googlesource.com/c/go/+/443380
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/debuglog.go
src/runtime/debuglog_test.go