Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: segfault when passing dtype module to np.array constructor #25031

Closed
@samuelstjean

Description

@samuelstjean

Describe the issue:

Passing nonsense to np.array can crash the whole intepreter.

Reproduce the code example:

#this worksnp.array(np.ones(10),dtype=None)#this also makes a sensible error because it is nonsensenp.array(np.ones(10),dtype=np.linalg)TypeError:Cannotinterpret'<module 'numpy.linalg' from '/home/samuel/miniconda3/envs/py310/lib/python3.10/site-packages/numpy/linalg/__init__.py'>'asadatatype# this will happily segfault and kick you out of your program, while it should probably do the same as above insteadnp.array(np.ones(10),dtype=np.dtype)

Error message:

Segfault message, or untranslated In [10]: np.array(np.ones(10), dtype=np.dtype)fish : Tâche Tâche 1,,'bash -c'ipython --pylab' $argv' terminée par le signal SIGSEGV (Erreur de frontière d'adresse)

Runtime information:

1.26.1
3.10.0 (default, Mar 3 2022, 09:58:08) [GCC 7.5.0]

In [1]: print(numpy.show_runtime())
[{'numpy_version': '1.26.1',
'python': '3.10.0 (default, Mar 3 2022, 09:58:08) [GCC 7.5.0]',
'uname': uname_result(system='Linux', node='samuel-dmri', release='5.15.0-87-generic', version='#97~20.04.1-Ubuntu SMP Thu Oct 5 08:25:28 UTC 2023', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'Haswell',
'filepath': '/home/samuel/miniconda3/envs/py310/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so',
'internal_api': 'openblas',
'num_threads': 16,
'prefix': 'libopenblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.23.dev'}]
None

Context for the issue:

Nothing bad, but it should probably just raise an error instead of crashing completely.

Not sure a traceback with gdb would be needed since it does not seems to be to obscure at first and easy to reproduce. I'd guess the np.dtype function/object just falls into the crack when you do not specify any dtype.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp