-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: fix reference counting bug in __array_interface__ implementation #27249
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Suggestion for a different solution, but not very important.
@@ -2233,7 +2233,8 @@ PyArray_FromInterface(PyObject *origin) | |||
} | |||
} | |||
} | |||
Py_DECREF(descr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just move the Py_DECREF(descr)
up inside the branch where descr
is defined? Outside of that branch, it is guaranteed to be NULL
(similarly, the definition of new_dtype
can be much closer to its use...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now looked at the original issue, where I see @seberg also noted it should be put up: reason is that if GetStringRef
returns 0, then the key was not present so descr
cannot have been set.
Thanks Nathan! |
This adds a simple regression test for the missing descr for numpygh-27249.
…numpy#27249) * BUG: fix reference counting bug in __array_interface__ implementation * MAINT: only decref if the reference is valid
This adds a simple regression test for the missing descr for numpygh-27249.
This adds a simple regression test for the missing descr for numpygh-27249.
…numpy#27249) * BUG: fix reference counting bug in __array_interface__ implementation * MAINT: only decref if the reference is valid
This adds a simple regression test for the missing descr for numpygh-27249.
@seberg ran into this testing
cunumeric
: https://github.com/numpy/numpy/pull/26282/files#r1722321473.Unfortunately there are no existing tests for this code path so we missed this breakage.
I tried writing an example that triggered this code path for a while this afternoon but was unable to.