BUG: sanity check __array_interface__ number of dimensions#28407
BUG: sanity check __array_interface__ number of dimensions#28407seberg merged 1 commit intonumpy:mainfrom
__array_interface__ number of dimensions#28407Conversation
c5ab096 to
ad293f5
Compare
seberg
left a comment
There was a problem hiding this comment.
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. |
seberg
left a comment
There was a problem hiding this comment.
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.
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.
@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.
__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.cto avoid segmentation faultnumpy/_core/tests/test_multiarray.py. If the test passes there's no longer a segmentation fault