runtime: GODEBUG=tracebacklabels=1 for 1.27+

https://go.dev/cl/742580 updated the goroutine label format in
tracebacks to only quote the values under some circumstances, and use a
more broadly acceptable format. Flip the GODEBUG=tracebacklabels default
for go 1.27+ modules.

Notably, tracebacklabels is marked as Opaque to avoid some diciness in
maintaining a usage metric in signal handlers, etc. (where mutex
acquisition may be problematic)

Also, update the go 1.27 release notes to call out the new feature.

Updates #76349

Change-Id: Iedd3f6b17d83e99da20365b952a565022d20ff13
Reviewed-on: https://go-review.googlesource.com/c/go/+/751580
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
This commit is contained in:
David Finkel
2026-03-04 16:34:24 -05:00
committed by Gopher Robot
parent 38ac6577cb
commit 3694f33692
4 changed files with 19 additions and 1 deletions

View File

@@ -167,6 +167,11 @@ escaped. Setting `htmlmetacontentescape=0` disables this behavior. To avoid
content injection attacks, this setting and default was backported to Go 1.25.8
and Go 1.26.1.
Go 1.27 changes the default for `tracebacklabels` (added in [Go 1.26][#go-126])
to `1`. This opt-out is expected to be kept indefinitely in case goroutine
labels acquire sensitive information that shouldn't be made available in
tracebacks.
### Go 1.26
Go 1.26 added a new `httpcookiemaxnum` setting that controls the maximum number

View File

@@ -1 +1,10 @@
## Runtime {#runtime}
<!-- CL 742580 -->
Tracebacks for modules with `go` directives configuring Go 1.27 or later will now
include [runtime/pprof](https://pkg.go.dev/runtime/pprof) goroutine labels in
the header line. This behavior can be disabled with `GODEBUG=tracebacklabels=0`
(added in [Go 1.26](/doc/godebug#go-126)). This opt-out is expected to be
kept indefinitely in case goroutine labels acquire sensitive information that
shouldn't be made available in tracebacks.

View File

@@ -68,6 +68,10 @@ var All = []Info{
{Name: "tlssecpmlkem", Package: "crypto/tls", Changed: 26, Old: "0", Opaque: true},
{Name: "tlssha1", Package: "crypto/tls", Changed: 25, Old: "1"},
{Name: "tlsunsafeekm", Package: "crypto/tls", Changed: 22, Old: "1"},
// Mark tracebacklabels as Opaque so we don't generate a metric that we can't increment.
// IncNonDefault uses a sync.Once, which involves sync.Mutex, and is not safe from a signal handler.
// (Tracebacks are generated in signal-handlers.)
{Name: "tracebacklabels", Package: "runtime", Changed: 27, Old: "0", Opaque: true},
{Name: "updatemaxprocs", Package: "runtime", Changed: 25, Old: "0"},
{Name: "urlmaxqueryparams", Package: "net/url", Changed: 24, Old: "0"},
{Name: "urlstrictcolons", Package: "net/url", Changed: 26, Old: "0"},

View File

@@ -398,7 +398,7 @@ var dbgvars = []*dbgVar{
{name: "traceallocfree", atomic: &debug.traceallocfree},
{name: "tracecheckstackownership", value: &debug.traceCheckStackOwnership},
{name: "tracebackancestors", value: &debug.tracebackancestors},
{name: "tracebacklabels", atomic: &debug.tracebacklabels, def: 0},
{name: "tracebacklabels", atomic: &debug.tracebacklabels, def: 1},
{name: "tracefpunwindoff", value: &debug.tracefpunwindoff},
{name: "updatemaxprocs", value: &debug.updatemaxprocs, def: 1},
}