-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: sanity check __array_interface__
number of dimensions
#28407
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
c5ab096
to
ad293f5
Compare
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.
Looks good, thanks. If we touch this, I think we might as well also fix the bug for ridiculously large tuples here (don't care for a test, since that would require a lot of memory to run).
I wasn't able to find an open issue related to large tuples. Is this a known problem or should we open an issue for it? |
f81eb97
to
e4c401b
Compare
Universal test failures. No there is no issue, just something to spot, |
@seberg ok I think I can make the change for the extremely large tuple that takes up memory. Is there a specific memory limit you had in mind? I can poke around this file, maybe there's a clue in here. I think I fixed the test failures. |
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.
First is a nit, but I don't like that new overflow check without reason much.
(I am not even sure it can be hit, but maybe it is possible with exact choice of itemsize and prod(shape)
)
numpy/_core/src/multiarray/ctors.c
Outdated
PyErr_SetString(PyExc_ValueError, | ||
"array is too big; overflow in _array_fill_strides."); | ||
return; | ||
} |
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.
Why? Can we please not do this? I am happy to check ridiculous tuple lengths one could claim them to be technically valid also since it is local to the __array_interface__
.
But this just can't be valid. Someone might as well pass a bad data pointer if they run into this.
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.
@seberg
Would it be ok to focus on the original bug fix in this PR and then I'll address the large tuple issue separately?
I wasn't able to reproduce the large tuple issue, but I can investigate it further in another PR.
I implemented your other suggestions in regards to converting n
and i
into type Py_ssize_t
.
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.
Thanks, @lvllvl.
__array_interface__
number of dimensions
…#28407) ``__array_interface__`` should typically not have more dimensions than NumPy supports, but unlike other malformed interfaces, this should fail gracefully if someone were to pass more.
Bug fix to #27949.
numpy/_core/src/multiarray/ctors.c
to avoid segmentation faultnumpy/_core/tests/test_multiarray.py
. If the test passes there's no longer a segmentation fault