BUG: fix out array leak in reduceat and accumulate when dtype resolution fails - #31699
Conversation
…ion fails Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
MaanasArora
left a comment
There was a problem hiding this comment.
Thanks, LGTM! (All other returns goto fail or finish.)
Pretty sure we don't need a test for this as well!
|
Yeah what one can do is also |
|
The descriptor array is set up for the ufunc branch, so I agree, this seems more natural! |
|
I agree we shouldn't be too strict about tests here, but it should be pretty easy to write one that hits this, right? But if not agreed, we can also just put it in (and I will in a bit). This bug leak looks very theoretical (i.e. not going to happen in production code). |
|
Sorry but I didn't understand what you meant with your comment here. The first sentence feels like is being contradicted by "I wouldn't worry about actually testing for the refcount leak" to me. What would you want to test here? The ref count is the leak no? Are you talking about a test that would just be caught by a sanitizer instead of asserting on the actual ref count number? I feel like the snippet in the PR description would be the test. |
|
I guess I would prefer to be sure to cover the error path at least. Testing for the leak is nice, but I am more willing to ignore it (but if you test with strings failing here, then we should already be testing for leaks implicitly). (But yes, I am only saying that because I don't want us to slip too casually into the "hard to test, let's skip it" territory.) |
|
There are a few different bugs related to this, but this one seems only about the leak right @seberg? There doesn't seem to be any other failure to detect... |
|
Sorry, yeah, I should have looked closer. Any test that covers Anyway, if you add one I am happy, if not I'll put it in tomorrow. |
|
LMK if what I added is what you had in mind. Indeed I wouldn't assert on the ref count either cause I think I've had cases in the past where a change in python version causes ref count assertions to fail in tests. Edit: the linting failure is not in code I'm touching here? What? |
seberg
left a comment
There was a problem hiding this comment.
Thanks, sorry for being obnoxious about adding tests :).
The lint failure, I'll ignore it: Not quite sure but the cython lint may be running process wide and maybe they had a release or so? (We'll have to fix it if it shows up generally, though.)
|
#31711 I think Joren's on it. |
…ion fails (#31699) Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
BUG: fix out array leak in reduceat and accumulate when dtype resolution fails (#31699)
Closes #31691
PR summary
In both of those cases
outreference count is incremented beforereducelike_promote_and_resolveis called but if the dtype resolution fails, it's not decremented. One can see it with a snippet like the following:Let me know if you think the above should be added as a test. I found it a trivial fix and not worthy of a specialized test personally.
First time committer introduction
N/A
AI Disclosure
No AI