Go版本
go版本:go1.22.5 darwin/arm64
在你的模块/工作区中运行go env
的输出:
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/toolchain@v0.0.1-go1.22.5.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/radu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.darwin-arm64/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'
你做了什么?
这是一个测试,用于添加、删除和克隆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
}
}
}
}
你看到了什么发生?
在压力下(-exec 'stress -p 10'
)运行它,并在几千次运行后得到以下结果:
=== 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/toolchain@v0.0.1-go1.22.5.darwin-arm64/src/runtime/panic.go:1023 +0x40 fp=0x14000066cf0 sp=0x14000066cc0 pc=0x1005cd780
runtime.sigpanic()
/Users/radu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.darwin-arm64/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/toolchain@v0.0.1-go1.22.5.darwin-arm64/src/runtime/map.go:1456 +0x38 fp=0x14000066de0 sp=0x14000066d60 pc=0x1005a5108
runtime.mapclone2(0x1008d7900, 0x14000516d80)
/Users/radu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.darwin-arm64/src/runtime/map.go:1538 +0x428 fp=0x14000066e80 sp=0x14000066de0 pc=0x1005a57e8
maps.clone({0x1008d7900, 0x14000516d80})
/Users/radu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.darwin-arm64/src/runtime/map.go:1448 +0x2c fp=0x14000066ea0 sp=0x14000066e80 pc=0x10060272c
maps.Clone[...](...)
/Users/radu/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.darwin-arm64/src/maps/maps.go:46
github.com/cockroachdb/pebble/vfs.TestMapClone(0x14000135040)
你期望看到什么?
没有崩溃。
8条答案
按热度按时间mm5n2pyu1#
注意:这与#62203类似,但它是一个不同的代码路径,此版本包含了该修复。
xurqigkl2#
CC @randall77@cuiweixie
vlurs2pr3#
这个错误似乎是很难复现的。
$x_{1}a_{0}b_{1}x$
vm0i2vca4#
@cuiweixie: are you sure it is actually running the test? On my machine (Apple M1), it can only do a couple hundred runs per 5s:
P.S. A friendly request - please don't post long irrelevant backtraces, it makes the issue hard to navigate. E.g. it would have been sufficient to post just
11m0s: 433534 runs so far, 0 failures, 10 active
.w46czmvw5#
对不起,我更改了迭代次数!
重新运行!
yx2lnoni6#
它花了大约7分钟才崩溃。但我现在再试一次,11分钟内没有崩溃。可能需要很长时间。
请注意,在 cockroachdb/pebble#3894 中,我们看到了地址0(
signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x417278]
)上的故障。查看代码,我不认为这是如何发生的,除非源指针被损坏并且接近uint64的末尾范围,导致我们在访问时发生溢出。rjee0c157#
我正在运行你的代码!
请勿复制!很悲伤!
xn1cxnb48#
这可能需要一段时间,我会将超时时间增加到例如1小时。我在不同版本的测试上运行了多次,直到我看到崩溃,所以它可能是一个特别幸运的运行。