Skip to content

Commit

Permalink
Ensure GIL is held when releasing nb::ndarray (fixes #377)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Dec 4, 2023
1 parent f9bc4dd commit a958e8d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/nb_ndarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ void ndarray_dec_ref(ndarray_handle *th) noexcept {
if (rc_value == 0) {
check(false, "ndarray_dec_ref(): reference count became negative!");
} else if (rc_value == 1) {
gil_scoped_acquire guard;

Py_XDECREF(th->owner);
Py_XDECREF(th->self);
managed_dltensor *mt = th->ndarray;
Expand Down

0 comments on commit a958e8d

Please sign in to comment.