Skip to content

BUG: fix free-threaded races in RandomState - #30400

Merged
charris merged 4 commits into
numpy:maintenance/2.4.xfrom
charris:backport-30360
Dec 9, 2025
Merged

BUG: fix free-threaded races in RandomState#30400
charris merged 4 commits into
numpy:maintenance/2.4.xfrom
charris:backport-30360

Conversation

@charris

@charris charris commented Dec 9, 2025

Copy link
Copy Markdown
Member

Backport of #30360.

Fixes one of the races in #30085.

I'd appreciate it if one of @lysnikolaou, @kumaraditya303, or @crusaderky could look this over, since you're all doing work related to this change.

I verified that the test I added generates TSan races without the cython change to add critical sections.

As far as I can tell, all other reads and writes to internal state are either atomic (e.g. in get_state) or are done with a threading.lock held and don't need any additional synchronization.

@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703) labels Dec 9, 2025
@charris
charris merged commit e309549 into numpy:maintenance/2.4.x Dec 9, 2025
73 checks passed
@charris
charris deleted the backport-30360 branch December 9, 2025 02:58
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 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants