Commit e4a100de authored by Kirill Smelkov's avatar Kirill Smelkov

X zodb: Disable Buf tests under race

It was failing in a strange way, e.g.

panic: Buf: refcnt < 0
fatal error: panic holding locks

goroutine 19 [running]:
runtime.throw(0x5f9d65, 0x13)
        /home/kirr/src/tools/go/go/src/runtime/panic.go:605 +0x95 fp=0xc42003cc20 sp=0xc42003cc00 pc=0x452935
panic(0x5c21c0, 0x611f60)
        /home/kirr/src/tools/go/go/src/runtime/panic.go:451 +0x585 fp=0xc42003ccc8 sp=0xc42003cc20 pc=0x4524c5
lab.nexedi.com/kirr/neo/go/zodb.(*Buf).Release(0xc4200900e0)
        /home/kirr/src/neo/src/lab.nexedi.com/kirr/neo/go/zodb/buffer.go:112 +0x161 fp=0xc42003ccf8 sp=0xc42003ccc8 pc=0x59ebc1
lab.nexedi.com/kirr/neo/go/zodb.TestBufAllocFree(0xc4200a80f0)
        /home/kirr/src/neo/src/lab.nexedi.com/kirr/neo/go/zodb/buffer_test.go:111 +0x6ae fp=0xc42003cf78 sp=0xc42003ccf8 pc=0x5a137e
testing.tRunner(0xc4200a80f0, 0x600930)
        /home/kirr/src/tools/go/go/src/testing/testing.go:746 +0x16d fp=0xc42003cfd0 sp=0xc42003cf78 pc=0x51688d
runtime.goexit()
        /home/kirr/src/tools/go/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42003cfd8 sp=0xc42003cfd0 pc=0x4835f1
created by testing.(*T).Run
        /home/kirr/src/tools/go/go/src/testing/testing.go:789 +0x569

goroutine 1 [chan receive]:
testing.(*T).Run(0xc4200a8000, 0x5f9180, 0x10, 0x600930, 0xc420051c50)
        /home/kirr/src/tools/go/go/src/testing/testing.go:790 +0x59b
testing.runTests.func1(0xc4200a8000)
        /home/kirr/src/tools/go/go/src/testing/testing.go:1004 +0xa8
testing.tRunner(0xc4200a8000, 0xc420051d90)
        /home/kirr/src/tools/go/go/src/testing/testing.go:746 +0x16d
testing.runTests(0xc420090040, 0x6ed4a0, 0x7, 0x7, 0x4159b0)
        /home/kirr/src/tools/go/go/src/testing/testing.go:1002 +0x522
testing.(*M).Run(0xc420051f20, 0x1d7ab28)
        /home/kirr/src/tools/go/go/src/testing/testing.go:921 +0x207
main.main()
        lab.nexedi.com/kirr/neo/go/zodb/_test/_testmain.go:56 +0x1d4
exit status 2
FAIL    lab.nexedi.com/kirr/neo/go/zodb 0.006s

becuase upon release object was not put back into pool, then we were
getting another object from pool, complainig but still doing
buf.Release.
parent bab79665
......@@ -17,6 +17,11 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// As of go19 sync.Pool under race-detector randomly drops items on the floor
// https://github.com/golang/go/blob/ca360c39/src/sync/pool.go#L92
// so it is not possible to verify we will get what we've just put there.
// +build !race
package zodb
import (
......@@ -53,16 +58,16 @@ func TestBufAllocFree(t *testing.T) {
}
if len(buf.Data) != size {
t.Errorf("%v: len=%v ; want %v", i, len(buf.Data), size)
t.Fatalf("%v: len=%v ; want %v", i, len(buf.Data), size)
}
if cap(buf.Data) != xcap {
t.Errorf("%v: cap=%v ; want %v", i, cap(buf.Data), xcap)
t.Fatalf("%v: cap=%v ; want %v", i, cap(buf.Data), xcap)
}
checkref := func(rc int32) {
t.Helper()
if buf.refcnt != rc {
t.Errorf("%v: refcnt=%v ; want %v", i, buf.refcnt, rc)
t.Fatalf("%v: refcnt=%v ; want %v", i, buf.refcnt, rc)
}
}
......@@ -77,14 +82,14 @@ func TestBufAllocFree(t *testing.T) {
// not from pool - memory won't be reused
if int(i) >= order0 + len(bufPoolv) {
if buf2 == buf || sliceDataPtr(buf2.Data) == sliceDataPtr(data) {
t.Errorf("%v: buffer reused but should not", i)
t.Fatalf("%v: buffer reused but should not", i)
}
continue
}
// from pool -> it must be the same
if !(buf2 == buf && sliceDataPtr(buf2.Data) == sliceDataPtr(data)) {
t.Errorf("%v: buffer not reused on free/realloc", i)
t.Fatalf("%v: buffer not reused on free/realloc", i)
}
checkref(0)
......@@ -99,7 +104,7 @@ func TestBufAllocFree(t *testing.T) {
checkref(0)
if buf2 == buf || sliceDataPtr(buf2.Data) == sliceDataPtr(data) {
t.Errorf("%v: buffer reused but should not", i)
t.Fatalf("%v: buffer reused but should not", i)
}
// release buf again -> should go to pool
......@@ -107,7 +112,7 @@ func TestBufAllocFree(t *testing.T) {
checkref(-1)
buf2 = BufAlloc(size)
if !(buf2 == buf && sliceDataPtr(buf2.Data) == sliceDataPtr(data)) {
t.Errorf("%v: buffer not reused on free/realloc", i)
t.Fatalf("%v: buffer not reused on free/realloc", i)
}
checkref(0)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment