[Numpy-svn] [numpy/numpy] 9cdff2: BUG: Remove data race in mtrand: two threads could...

GitHub noreply at github.com
Mon Feb 22 17:45:07 EST 2016


  Branch: refs/heads/master
  Home:   https://github.com/numpy/numpy
  Commit: 9cdff27107b5feb0f6bfe5c408970716b19aa93d
      https://github.com/numpy/numpy/commit/9cdff27107b5feb0f6bfe5c408970716b19aa93d
  Author: Devin Jeanpierre <jeanpierreda at google.com>
  Date:   2016-02-22 (Mon, 22 Feb 2016)

  Changed paths:
    M numpy/random/mtrand/mtrand.pyx

  Log Message:
  -----------
  BUG: Remove data race in mtrand: two threads could mutate the state.

E.g.:

np.random.random_sample() uses the GIL for synchronization
np.random.random_sample(1) releases the GIL and uses a separate lock.

This means that both can run simultaneously, causing a data race when mutating
the random number generator's state, which could lead to buffer overflow (from
incrementing state->pos).

The fix here is to always use the separate lock, so that exactly one thread at
a time is mutating the random number generator's state.


  Commit: a51655578df2fb1cfe161887cc6414120d0cf8c5
      https://github.com/numpy/numpy/commit/a51655578df2fb1cfe161887cc6414120d0cf8c5
  Author: Julian Taylor <juliantaylor108 at gmail.com>
  Date:   2016-02-22 (Mon, 22 Feb 2016)

  Changed paths:
    M numpy/random/mtrand/mtrand.pyx

  Log Message:
  -----------
  Merge pull request #7305 from ssbr/ssbr-racy-mtrand

BUG: Remove data race in mtrand: two threads could mutate the state.


Compare: https://github.com/numpy/numpy/compare/0dbcd2fd49db...a51655578df2


More information about the Numpy-svn mailing list