Skip to content

BUG: segfault in array_richcompare #5960

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

Closed
wants to merge 1 commit into from
Closed

Conversation

ahaldane
Copy link
Member

Fixes #4855. Only real change was Py_DECREF(result) became Py_XDECREF(result).

I assume the other logic there is fine, I don't know ufunc code very well.

@@ -1358,18 +1358,17 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
_res = PyArray_CanCastTypeTo(PyArray_DESCR(self),
PyArray_DESCR(array_other),
NPY_EQUIV_CASTING);
Py_XDECREF(result);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite right here (or below), as a NULL return indicates that PyArray_GenericBinaryFunction encountered an error. Probably something like

if (result == NULL) {
    PyErr_Clear();
}
else {
    Py_DECREF(result);
}

Somehow I think the logic in this function can be cleaned up, but that might be for another day.

@ahaldane ahaldane force-pushed the fix4855 branch 2 times, most recently from a696688 to bee7fe5 Compare June 12, 2015 14:45
@ahaldane
Copy link
Member Author

That makes a lot more sense, I had thought TypeError was the expected output.

Updated + added a test.

@ahaldane
Copy link
Member Author

Oh, I just noticed that #5864 probably fixes this in a better way. Feel free to take the unit test for use there, if wanted.

@charris
Copy link
Member

charris commented Jun 14, 2015

I copied the test to #5965. The problem should be fixed by #5964, so closing this and the issue. Thanks for the work.

@charris charris closed this Jun 14, 2015
charris referenced this pull request Jun 14, 2015
TST: Add test for segfault in richcompare of void type ==, !=.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants