GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing github.com — BUG: ensure lock is held when accessing or writing to RNG state by ngoldbaum · Pull Request #32061 · numpy/numpy Conversation
|
| if st['bit_generator'] != 'MT19937' and legacy: | ||
| warnings.warn('get_state and legacy can only be used with the ' | ||
| 'MT19937 BitGenerator. To silence this warning, ' | ||
| 'set `legacy` to False.', RuntimeWarning) | ||
| legacy = False |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
might as well move the state access and the warning into the lock's critical section
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The errors are unrelated. Thanks Nathan. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The fix is correct and it covers all places. In future I would like PRs to be left open for atleast a day so that I get time to review it before merge. Thanks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
BUG: ensure lock is held when accessing or writing to RNG state (#32061)
Port NumPy's lock changes (numpy/numpy#30360, numpy/numpy#32061) so bit generators are safe to share across threads on free-threaded Python. - Always use an RLock, since NumPy < 2.5 provides a plain Lock that deadlocks when locked calls nest; RDRAND's RaisingLock wraps an RLock - Lock state get/set, seeding (including key=/counter= paths), advance and jump in every bit generator and in UserBitGenerator - Validate state before writing in the AES, Philox and ThreeFry setters so a bad state no longer leaves the generator half updated - Lock the scalar path of ExtendedGenerator.complex_normal - Declare the extensions free-threading compatible when built with Cython >= 3.1 so importing randomgen does not re-enable the GIL - Add threaded tests covering seed/state races, reentrancy and the GIL Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
BUG: Data race reading and writing np.random.seed
There was an error while loading. Please reload this page.