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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG: avoid deadlocks with C++ shared mutex in dispatch cache
  • Loading branch information
ngoldbaum authored and charris committed Mar 24, 2025
commit 37985a2a900a304ab102fdd692f4ad3920fd797e
4 changes: 4 additions & 0 deletions 4 numpy/_core/src/umath/dispatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,9 @@ promote_and_get_info_and_ufuncimpl_with_locking(
npy_bool legacy_promotion_is_possible)
{
std::shared_mutex *mutex = ((std::shared_mutex *)((PyArrayIdentityHash *)ufunc->_dispatch_cache)->mutex);
NPY_BEGIN_ALLOW_THREADS
mutex->lock_shared();
NPY_END_ALLOW_THREADS
PyObject *info = PyArrayIdentityHash_GetItem(
(PyArrayIdentityHash *)ufunc->_dispatch_cache,
(PyObject **)op_dtypes);
Expand All @@ -926,7 +928,9 @@ promote_and_get_info_and_ufuncimpl_with_locking(

// cache miss, need to acquire a write lock and recursively calculate the
// correct dispatch resolution
NPY_BEGIN_ALLOW_THREADS
mutex->lock();
NPY_END_ALLOW_THREADS
info = promote_and_get_info_and_ufuncimpl(ufunc,
ops, signature, op_dtypes, legacy_promotion_is_possible);
mutex->unlock();
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.