Skip to content

BUG: ensure lock is held when accessing or writing to RNG state (#32061) - #32122

Merged
charris merged 1 commit into
numpy:maintenance/2.5.xfrom
charris:backport-32061
Jul 27, 2026
Merged

BUG: ensure lock is held when accessing or writing to RNG state (#32061)#32122
charris merged 1 commit into
numpy:maintenance/2.5.xfrom
charris:backport-32061

Conversation

@charris

@charris charris commented Jul 27, 2026

Copy link
Copy Markdown
Member

Backport of #32061.

PR summary

Fixes #32059.

#30360 was supposed to fix these issues but clearly this is harder than I thought.

With this PR the lock is being held everywhere we access the RNG state. Also adds new tests for the case from the issue as well as some other spots I noticed while auditing the RNG codebase for similar issues.

I was able to reproduce the race in a slightly modified version of the script in the issue and it no longer triggers after this PR.

AI Disclosure

I used an AI model to find places where we access RNG state without holding the lock. It also helped with the new tests.

@charris charris added this to the 2.5.2 release milestone Jul 27, 2026
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Jul 27, 2026
@charris
charris merged commit adc5cdc into numpy:maintenance/2.5.x Jul 27, 2026
86 checks passed
@charris
charris deleted the backport-32061 branch July 27, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

00 - Bug 08 - Backport Used to tag backport PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants