Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

ngoldbaum
Copy link
Member

@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.

@ngoldbaum ngoldbaum added the 09 - Backport-Candidate PRs tagged should be backported label Aug 19, 2024
@charris charris added this to the 2.1.1 release milestone Aug 19, 2024
Copy link
Contributor

@mhvk mhvk left a 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);
Copy link
Contributor

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...).

Copy link
Contributor

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.

@seberg seberg merged commit 16d6996 into numpy:main Aug 21, 2024
66 checks passed
@seberg
Copy link
Member

seberg commented Aug 21, 2024

Thanks Nathan!

seberg added a commit to seberg/numpy that referenced this pull request Aug 21, 2024
This adds a simple regression test for the missing descr for
numpygh-27249.
charris pushed a commit to charris/numpy that referenced this pull request Aug 22, 2024
…numpy#27249)

* BUG: fix reference counting bug in __array_interface__ implementation

* MAINT: only decref if the reference is valid
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Aug 22, 2024
charris pushed a commit to charris/numpy that referenced this pull request Aug 22, 2024
This adds a simple regression test for the missing descr for
numpygh-27249.
charris pushed a commit to charris/numpy that referenced this pull request Aug 22, 2024
This adds a simple regression test for the missing descr for
numpygh-27249.
@charris charris removed this from the 2.1.1 release milestone Aug 28, 2024
ArvidJB pushed a commit to ArvidJB/numpy that referenced this pull request Nov 1, 2024
…numpy#27249)

* BUG: fix reference counting bug in __array_interface__ implementation

* MAINT: only decref if the reference is valid
ArvidJB pushed a commit to ArvidJB/numpy that referenced this pull request Nov 1, 2024
This adds a simple regression test for the missing descr for
numpygh-27249.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants