Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix race initializing legacy dtype casts #28321

Merged
merged 15 commits into from
Feb 11, 2025

Conversation

charris
Copy link
Member

@charris charris commented Feb 11, 2025

Backport of #28290.

Fixes #28048

Locks castingimpls with a critical section when the castingimpls cache is empty before writing to the dict.

Because the critical section macros have braces, I refactored PyArray_GetCastingImpl into three functions that call each other. Only the "middle" function needs the critical section, so that reduces the pain of not being able to early return in a critical section a little bit.

I also added some comments because this took me quite a while to fully understand so future readers will hopefully be less confused.

Edit: there are also some unrelated fixes for the test infrastructure to avoid CI crashes and generate better debug output from CI jobs. Happy to do those separately if anyone requests.

@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 Feb 11, 2025
- Checkout numpy/testing/_private/utils.py
- Checkout numpy/_core/tests/test_multithreading.py
- Checkout conftest.py
- Update test_requirements.txt
@charris charris merged commit 56f8d5b into numpy:maintenance/2.2.x Feb 11, 2025
65 of 69 checks passed
@charris charris deleted the backport-28290 branch February 11, 2025 22:02
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.

None yet

2 participants