math/rand: fix raciness in Rand.Read
There are no synchronization points protecting the readVal and readPos variables. This leads to a race when Read is called concurrently. Fix this by adding methods to lockedSource, which is the case where a race matters. Fixes #16308. Change-Id: Ic028909955700906b2d71e5c37c02da21b0f4ad9 Reviewed-on: https://go-review.googlesource.com/24852Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Showing
src/math/rand/race_test.go
0 → 100644
Please register or sign in to comment