-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Adds missing Py_INCREF in array_boolean_subscript #4494
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
numpy/core/src/multiarray/mapping.c
Outdated
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.
Can omit the blank line, Py_INCREF(dtype); naturally goes with the next line of code.
The function is a bit overspaced as is ;)
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.
Yes, probably best to group them together.
|
LGTM. Could you squash the two commits into one and rewrite the commit message. Something like |
|
thanks for debugging that for us :) |
|
@juliantaylor I thought of doing that, but given that the failure result is unpredictable and possibly a segfault was troubling. Should I just go with it anyways? |
|
yes, a test that finds an issue sometimes is better than none, that its segfaulting is no problem |
|
@embray Could you finish this up? I would like to backport it for the 1.8.1 release. |
|
this doesn't affect 1.8.x, it got introduced in the indexing rewrite |
BUG: Adds missing Py_INCREF in array_boolean_subscript
test for numpygh-4494 test median returns array scalars and works with object arrays
|
Sorry I didn't get a chance to finish this up--got sidetracked by other tasks for the last few days. Thanks! |
This bug was introduced, as far as I can tell, in 52b4a94. It came up in the context of astropy/astropy#1987 where we were getting semi-irregular segfaults. The problem is that after this line a new array is created with
PyArray_NewFromDescrusing an existing dtype object, but it does not incref that dtype object.A reliable way that I found to demonstrate this bug was something like:
at this point various different things could happen, but most often it just results in a segfault.