]> Cypherpunks repositories - gostls13.git/commit
math/rand: fix raciness in Rand.Read
authorIan Lance Taylor <iant@golang.org>
Sun, 10 Jul 2016 02:38:04 +0000 (19:38 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 11 Jul 2016 15:11:44 +0000 (15:11 +0000)
commitfb3cf5c686b09bab8c1bef5f7589aaef0e6d9712
tree34d2a1beedc79a278590d0877b34e378709101ca
parent54ffdf364f77c62ffeb205debe26347ca5961373
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/24852
Reviewed-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>
src/math/rand/race_test.go [new file with mode: 0644]
src/math/rand/rand.go