-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: numpy.asarray
's boundary check fails with too large shape and got a segmentation fault
#27949
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
Comments
Thanks. While use of this interface is clearly completely unsafe, I agree that this should be checked. |
Hi @seberg, I think I have a solution for this. Also are tests required for bug fixes? |
Yes of course, everything needs tests. Codespaces should work fine as well, did you follow the instructions in the developer guide? They should work, code-spaces or not. Anyway, please just open a PR, including a test. |
ok great, thanks for clarifying @seberg I was able to include some tests and get it to work. Do you mind taking a look at my PR when you get a chance? Here's a link: PR #28407 |
Describe the issue:
Actually, I first triggered this Segmentation Fault when calling
np.lib.stride_tricks.as_strided
. After reading the implementation ofnp.lib.stride_tricks.as_strided
, I found it is a problem withnp.asanyarray
.np.asanyarray
does have a 'guard' for its argument, if you pass into a DummArray whoseinterface.shape
is bigger than 64 and smaller than 136, it raises a ValueError: number of dimensions must be within [0, 64].But this 'guard' fails when the size
interface.shape
is larger than 135, and a Segmentation Fault is achieved.Reproduce the code example:
Error message:
Python and NumPy Versions:
2.2.0
3.12.7 | packaged by Anaconda, Inc. | (main, Oct 4 2024, 13:27:36) [GCC 11.2.0]
Runtime Environment:
[{'numpy_version': '2.2.0',
'python': '3.12.7 | packaged by Anaconda, Inc. | (main, Oct 4 2024, '
'13:27:36) [GCC 11.2.0]',
'uname': uname_result(system='Linux', node='a475b702ecc0', release='5.4.0-150-generic', version='#167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX'],
'not_found': ['AVX512_KNL',
'AVX512_KNM',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'SkylakeX',
'filepath': '/root/miniconda3/envs/py312/lib/python3.12/site-packages/numpy.libs/libscipy_openblas64_-6bb31eeb.so',
'internal_api': 'openblas',
'num_threads': 64,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.28'}]
Context for the issue:
I thought the boundary check for
numpy.asanyarray
can be improved.The text was updated successfully, but these errors were encountered: