Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: avoid deadlocks with C++ shared mutex in dispatch cache #28583

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

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

charris
Copy link
Member

@charris charris commented Mar 24, 2025

Backport of #28577.

@pitrou correctly pointed out here that the C++ shared_mutex we use in the dispatch might deadlock with the GIL (if it's re-enabled) or other global synchronization events in the interpreter, and we need to explicitly call Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS around a possibly blocking call.

I don't have a case where a deadlock happens right now, so no new test. Happy to add one if someone can come up with a way to trigger the deadlock.

I ran the test script from #27786 and don't see any performance hit.

@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 Mar 24, 2025
@charris charris added this to the 2.2.5 release milestone Mar 24, 2025
@charris charris merged commit 10632f9 into numpy:maintenance/2.2.x Mar 24, 2025
70 checks passed
@charris charris deleted the backport-28577 branch March 24, 2025 22:47
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.