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
When running tests which use this package with the race detector it finds out there are data races.
Trivial to reproduce example is with the following useless program:
package main
import"syreclabs.com/go/faker"funcmain() {
gofaker.RandomString(10)
gofaker.RandomString(10)
}
When I run it with go run -race this is the output from go's race detector:
==================
WARNING: DATA RACE
Read at 0x00c42018afb8 by goroutine 7:
math/rand.read()
/usr/lib/go/src/math/rand/rand.go:265 +0x3c
math/rand.(*Rand).Read()
/usr/lib/go/src/math/rand/rand.go:261 +0x16d
syreclabs.com/go/faker.RandomString()
/home/kiril/go/src/syreclabs.com/go/faker/faker.go:90 +0xb2
Previous write at 0x00c42018afb8 by goroutine 6:
math/rand.read()
/usr/lib/go/src/math/rand/rand.go:276 +0xee
math/rand.(*Rand).Read()
/usr/lib/go/src/math/rand/rand.go:261 +0x16d
syreclabs.com/go/faker.RandomString()
/home/kiril/go/src/syreclabs.com/go/faker/faker.go:90 +0xb2
Goroutine 7 (running) created at:
main.main()
/tmp/fake.go:7 +0x6c
Goroutine 6 (finished) created at:
main.main()
/tmp/fake.go:6 +0x4b
==================
==================
WARNING: DATA RACE
Read at 0x00c42018afb0 by goroutine 7:
math/rand.read()
/usr/lib/go/src/math/rand/rand.go:266 +0x56
math/rand.(*Rand).Read()
/usr/lib/go/src/math/rand/rand.go:261 +0x16d
syreclabs.com/go/faker.RandomString()
/home/kiril/go/src/syreclabs.com/go/faker/faker.go:90 +0xb2
Previous write at 0x00c42018afb0 by goroutine 6:
math/rand.read()
/usr/lib/go/src/math/rand/rand.go:277 +0x108
math/rand.(*Rand).Read()
/usr/lib/go/src/math/rand/rand.go:261 +0x16d
syreclabs.com/go/faker.RandomString()
/home/kiril/go/src/syreclabs.com/go/faker/faker.go:90 +0xb2
Goroutine 7 (running) created at:
main.main()
/tmp/fake.go:7 +0x6c
Goroutine 6 (finished) created at:
main.main()
/tmp/fake.go:6 +0x4b
==================
Found 2 data race(s)
exit status 66
Now, this makes a lot of sense, since math/rand.Rand.Read is documented as not safe to be called concurrently. Which is okay for a method of type. RandomString in this package however is a global function and this issue could not be worked around as easily as with Rand.Read. For instance math/rand.Read (the global function) is safe to be called concurrently.
The text was updated successfully, but these errors were encountered:
When running tests which use this package with the race detector it finds out there are data races.
Trivial to reproduce example is with the following useless program:
When I run it with
go run -race
this is the output from go's race detector:Now, this makes a lot of sense, since
math/rand.Rand.Read
is documented as not safe to be called concurrently. Which is okay for a method of type.RandomString
in this package however is a global function and this issue could not be worked around as easily as withRand.Read
. For instancemath/rand.Read
(the global function) is safe to be called concurrently.The text was updated successfully, but these errors were encountered: