Go version
go version go1.22.5 darwin/arm64
Output of go env in your module/workspace:
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/radu/Library/Caches/go-build'
GOENV='/Users/radu/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/radu/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/radu/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/radu/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/radu/go/pkg/mod/golang.org/[email protected]/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/radu/go/src/github.com/cockroachdb/pebble/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/x0/5yrxw_4s271g705vjscld23c0000gq/T/go-build2422055407=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
This is a test that adds, removes, and clones a map:
func TestMapClone(t *testing.T) {
seed := time.Now().UnixNano()
t.Logf("seed: %d", seed)
rng := rand.New(rand.NewSource(seed))
for i := 0; i < 100; i++ {
keyRange := 1 + rng.Intn(100)
clone := make(map[string]int)
m := make(map[string]int)
for j := 0; j < 10000; j++ {
switch rng.Intn(10) {
case 0, 1, 2, 3, 4:
m[fmt.Sprint(rng.Intn(keyRange))] = j
case 5, 6, 7, 8:
delete(m, fmt.Sprint(rng.Intn(keyRange)))
case 9:
clone = maps.Clone(m)
}
if rng.Intn(100) == 0 {
// Revert to the last clone.
m = clone
}
}
}
}
What did you see happen?
Ran it under stress (-exec 'stress -p 10') and got this (after a few thousand runs):
=== RUN TestMapClone
mem_fs_test.go:210: seed: 1724860257984210000
unexpected fault address 0x3731373330313337
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x2 addr=0x3731373330313337 pc=0x1005a5108]
goroutine 19 gp=0x14000104fc0 m=0 mp=0x100b594c0 [running]:
runtime.throw({0x10081e604?, 0x1009018c0?})
/Users/radu/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:1023 +0x40 fp=0x14000066cf0 sp=0x14000066cc0 pc=0x1005cd780
runtime.sigpanic()
/Users/radu/go/pkg/mod/golang.org/[email protected]/src/runtime/signal_unix.go:895 +0x22c fp=0x14000066d50 sp=0x14000066cf0 pc=0x1005e786c
runtime.moveToBmap(0x1008d7900, 0x14000516ff0, 0x14000066e28?, 0x1005a7d40?, 0x3731373330313337)
/Users/radu/go/pkg/mod/golang.org/[email protected]/src/runtime/map.go:1456 +0x38 fp=0x14000066de0 sp=0x14000066d60 pc=0x1005a5108
runtime.mapclone2(0x1008d7900, 0x14000516d80)
/Users/radu/go/pkg/mod/golang.org/[email protected]/src/runtime/map.go:1538 +0x428 fp=0x14000066e80 sp=0x14000066de0 pc=0x1005a57e8
maps.clone({0x1008d7900, 0x14000516d80})
/Users/radu/go/pkg/mod/golang.org/[email protected]/src/runtime/map.go:1448 +0x2c fp=0x14000066ea0 sp=0x14000066e80 pc=0x10060272c
maps.Clone[...](...)
/Users/radu/go/pkg/mod/golang.org/[email protected]/src/maps/maps.go:46
github.com/cockroachdb/pebble/vfs.TestMapClone(0x14000135040)
What did you expect to see?
No crash.
Go version
go version go1.22.5 darwin/arm64
Output of
go envin your module/workspace:What did you do?
This is a test that adds, removes, and clones a map:
What did you see happen?
Ran it under stress (
-exec 'stress -p 10') and got this (after a few thousand runs):What did you expect to see?
No crash.