Skip to content

BUG: lexsort segfaults on StringDType #27984

@otsaloma

Description

@otsaloma

Describe the issue:

Hi! I've been switching some code to the new StringDType and I came across a segfault when feeding StringDType arrays to lexsort. The example below is the same as in the documentation for lexsort: https://numpy.org/doc/stable/reference/generated/numpy.lexsort.html

Reproduce the code example:

#!/usr/bin/env python3

import numpy as np
from numpy.dtypes import StringDType

# Works
surnames =    ('Hertz',    'Galilei', 'Hertz')
first_names = ('Heinrich', 'Galileo', 'Gustav')
ind = np.lexsort((first_names, surnames))
print(ind)

# Works
surnames2 = np.array(surnames, str)
first_names2 = np.array(first_names, str)
ind = np.lexsort((first_names2, surnames2))
print(ind)

# Segfaults
surnames2 = np.array(surnames, StringDType())
first_names2 = np.array(first_names, StringDType())
ind = np.lexsort((first_names2, surnames2))
print(ind)

Error message:

No response

Python and NumPy Versions:

2.2.0
3.12.8 (main, Dec  4 2024, 12:15:27) [GCC 14.2.0]

Runtime Environment:

[{'numpy_version': '2.2.0',
  'python': '3.12.8 (main, Dec  4 2024, 12:15:27) [GCC 14.2.0]',
  'uname': uname_result(system='Linux', node='thalatta', release='6.11.10-amd64', version='#1 SMP PREEMPT_DYNAMIC Debian 6.11.10-1 (2024-11-23)', 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': '.../venv/lib/python3.12/site-packages/numpy.libs/libscipy_openblas64_-6bb31eeb.so',
  'internal_api': 'openblas',
  'num_threads': 8,
  'prefix': 'libscipy_openblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.28'}]

Context for the issue:

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions