You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
14564:3350c94fe6b7 tip
Add the following test to encoding/gob package:
func TestStressParallel(t *testing.T) {
type T2 struct{ A int }
c := make(chan bool)
const N = 10
for i := 0; i < N; i++ {
go func() {
p := new(T2)
Register(p)
b := new(bytes.Buffer)
enc := NewEncoder(b)
err := enc.Encode(p)
if err != nil {
t.Error("encoder fail:", err)
}
dec := NewDecoder(b)
err = dec.Decode(p)
if err != nil {
t.Error("decoder fail:", err)
}
c <- true
}()
}
for i := 0; i < N; i++ {
<-c
}
}
go test -race says:
WARNING: DATA RACE
Read by goroutine 69:
encoding/gob.RegisterName()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type.go:729 +0xde
encoding/gob.Register()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type.go:785 +0x202
encoding/gob.func·023()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type_test.go:201 +0x4d
Previous write by goroutine 68:
encoding/gob.RegisterName()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type.go:738 +0x26d
encoding/gob.Register()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type.go:785 +0x202
encoding/gob.func·023()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type_test.go:201 +0x4d
Goroutine 69 (running) created at:
encoding/gob.TestParallel()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type_test.go:214 +0xac
testing.tRunner()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/testing/testing.go:301 +0x86
Goroutine 68 (running) created at:
encoding/gob.TestParallel()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/encoding/gob/type_test.go:214 +0xac
testing.tRunner()
/usr/local/google/home/dvyukov/go_prefetch/src/pkg/testing/testing.go:301 +0x86
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: