]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: skip tests for GOEXPERIMENT=arenas that do not handle clobberfree=1
authorthepudds <thepudds1460@gmail.com>
Wed, 5 Nov 2025 17:18:49 +0000 (12:18 -0500)
committert hepudds <thepudds1460@gmail.com>
Fri, 14 Nov 2025 21:37:37 +0000 (13:37 -0800)
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>
src/runtime/arena_test.go
src/runtime/export_test.go

index ca5223b59c998352d944dca874d21657e488d71d..0bb1950464a1e13f524e17c3cac08107039013d4 100644 (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.
index d17984881d4323de3e0d47b65cbdf15c2f6575e7..731ba5d6b97737b81c36057a5a5f92496ea6ba3f 100644 (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