Skip to content

BUG: resize causes segfault in case of arreys with structured dtype #27225

@avalentino

Description

@avalentino

Describe the issue:

Calling the .resize method in arrays with structured dtype causes segmentation fault.
If has been verified with Numpy v2.1.0rc1 and v2.2.0.dev0+git20240813.ab2f5e9.
Numpy v2.0.x work as expected instead.

Reproduce the code example:

>>> import numpy as np
>>> np.__version__
'2.2.0.dev0+git20240813.ab2f5e9'
>>> a = np.array([(i, float(i)) for i in range(5)], dtype='u4,f4')
>>> a.resize((10,))

Error message:

Segmentation fault

Python and NumPy Versions:

  • Python v3.12
  • Numpy v2.1.0rc1 and v2.2.0.dev0+git20240813.ab2f5e9

Runtime Environment:

>>> import numpy; numpy.show_runtime()
[{'numpy_version': '2.1.0rc1',
  'python': '3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0]',
  'uname': uname_result(system='Linux', node='XPS-13-9300', release='6.8.0-40-generic', version='#40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul  5 10:34:03 UTC 2024', machine='x86_64')},
 {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2',
                                'AVX512F',
                                'AVX512CD',
                                'AVX512_SKX',
                                'AVX512_CLX',
                                'AVX512_CNL',
                                'AVX512_ICL'],
                      'not_found': ['AVX512_KNL', 'AVX512_KNM']}}]

Context for the issue:

We are in the process of releasing an hotfix version for PyTables (v3.10.1, see also PyTables/PyTables#1206) and we have a red light in our CI.
If the bug cannot be fixed in numpy 2.1 we could try to implement an workaround on our side but we would prefer to keep the code clean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions