runtime: skip tests for GOEXPERIMENT=arenas that do not handle clobberfree=1

When run with GODEBUG=clobberfree=1, three out of seven of the top-level
tests in runtime/arena_test.go fail with a SIGSEGV inside the
clobberfree function where it is overwriting freed memory
with 0xdeadbeef.

This is not a new problem. For example, this crashes in Go 1.20:

  GODEBUG=clobberfree=1 go test runtime -run=TestUserArena

It would be nice for all.bash to pass with GODEBUG=clobberfree=1,
including it is useful for testing the automatic reclaiming of
dead memory via runtime.freegc in #74299.

Given the GOEXPERIMENT=arenas in #51317 is not planned to move forward
(and is hopefully slated to be replace by regions before too long),
for now we just skip those three tests in order to get all.bash
passing with GODEBUG=clobberfree=1.

Updates #74299

Change-Id: I384d96791157b30c73457d582a45dd74c5607ee0
Reviewed-on: https://go-review.googlesource.com/c/go/+/715080
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
This commit is contained in:
thepudds 2025-11-05 12:18:49 -05:00 committed by t hepudds
parent cb0d9980f5
commit 1a03d0db3f
2 changed files with 21 additions and 0 deletions

View file

@ -36,6 +36,11 @@ type largeScalar [UserArenaChunkBytes + 1]byte
type largePointer [UserArenaChunkBytes/unsafe.Sizeof(&smallPointer{}) + 1]*smallPointer
func TestUserArena(t *testing.T) {
if Clobberfree() {
// This test crashes with SEGV in clobberfree in mgcsweep.go with GODEBUG=clobberfree=1.
t.Skip("triggers SEGV with GODEBUG=clobberfree=1")
}
// Set GOMAXPROCS to 2 so we don't run too many of these
// tests in parallel.
defer GOMAXPROCS(GOMAXPROCS(2))
@ -228,6 +233,11 @@ func runSubTestUserArenaSlice[S comparable](t *testing.T, value []S, parallel bo
}
func TestUserArenaLiveness(t *testing.T) {
if Clobberfree() {
// This test crashes with SEGV in clobberfree in mgcsweep.go with GODEBUG=clobberfree=1.
t.Skip("triggers SEGV with GODEBUG=clobberfree=1")
}
t.Run("Free", func(t *testing.T) {
testUserArenaLiveness(t, false)
})
@ -320,6 +330,11 @@ func testUserArenaLiveness(t *testing.T, useArenaFinalizer bool) {
}
func TestUserArenaClearsPointerBits(t *testing.T) {
if Clobberfree() {
// This test crashes with SEGV in clobberfree in mgcsweep.go with GODEBUG=clobberfree=1.
t.Skip("triggers SEGV with GODEBUG=clobberfree=1")
}
// This is a regression test for a serious issue wherein if pointer bits
// aren't properly cleared, it's possible to allocate scalar data down
// into a previously pointer-ful area, causing misinterpretation by the GC.

View file

@ -238,6 +238,12 @@ func SetEnvs(e []string) { envs = e }
const PtrSize = goarch.PtrSize
const ClobberdeadPtr = clobberdeadPtr
func Clobberfree() bool {
return debug.clobberfree != 0
}
var ForceGCPeriod = &forcegcperiod
// SetTracebackEnv is like runtime/debug.SetTraceback, but it raises