-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
BUG: Prevent stackoverflow on self-containing arrays #9077
Conversation
numpy/core/src/multiarray/number.c
Outdated
@@ -786,10 +786,15 @@ static int | |||
_array_nonzero(PyArrayObject *mp) | |||
{ | |||
npy_intp n; | |||
int res; |
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 be put into the lower if scope
numpy/core/src/multiarray/number.c
Outdated
|
||
n = PyArray_SIZE(mp); | ||
if (n == 1) { | ||
return PyArray_DESCR(mp)->f->nonzero(PyArray_DATA(mp), mp); | ||
if (Py_EnterRecursiveCall(" while converting array to bool")) |
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.
needs curly braces
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.
Oops, was just copying cpython there
Approaches numpy#8306. This still errors, but it does so at a python level, without a segfault.
bba5738
to
00f7710
Compare
@juliantaylor: Fixed |
needs a test, then lgtm |
Tests added - seems that we weren't testing |
numpy/core/tests/test_multiarray.py
Outdated
try: | ||
Error = RecursionError | ||
except NameError: | ||
Error = RuntimeError |
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.
should also have a python 2
comment
3e37c07
to
db0041d
Compare
thanks |
For some reason, this doesn't fix |
|
Can we remove that deprecation in 1.14? We're now at the two year mark |
probably not, as far as I recall that was one that caused enough noise to come up on the mailing list, but then I am of the opinion that deprecations are to almost never be removed, others might disagree. |
Well in that case, the deprecation message shouldn't have been "this will raise an error in the future" ;). But fair enough, perhaps 1.14 is too soon |
Approaches #8306. This still errors, but it does so at a python level, without
a segfault.
This makes the following not segfault:
On the other hand, it still behaves incorrectly
But that's a different bug (#9078)