Skip to content

BUG: Crash in np.unravel_index if debug assertions enabled. #29690

Description

@hawkinsp

Describe the issue:

In a debug build of NumPy:

In [1]: import numpy as np

In [2]: np.unravel_index(np.array([[1, 0, 1, 0]], dtype=np.uint32), (4,))
python3: ../numpy/_core/src/multiarray/nditer_constr.c:2081: npyiter_find_buffering_setup: Assertion `(axisdata->shape == 1) ? (prev_strides[iop] == strides[iop]) : 1' failed.

Reproduce the code example:

import numpy as np
np.unravel_index(np.array([[1, 0, 1, 0]], dtype=np.uint32), (4,))

Error message:

See above.

Python and NumPy Versions:

2.4.0.dev0+git20250905.366c0a3
3.12.10 (main, Apr 9 2025, 04:03:51) [Clang 20.1.0 ]

This also reproduces in 2.3.2.

Runtime Environment:

[{'numpy_version': '2.4.0.dev0+git20250905.366c0a3',
'python': '3.12.10 (main, Apr 9 2025, 04:03:51) [Clang 20.1.0 ]',
'uname': uname_result(system='Linux', node='redacted', release='6.12.32-redacted-amd64', version='#1 SMP PREEMPT_DYNAMIC Debian 6.12.32-redacted (2025-06-26)', machine='x86_64')},
{'simd_extensions': {'baseline': [], 'found': [], 'not_found': []}},
{'architecture': 'Zen',
'filepath': '/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.29.so',
'internal_api': 'openblas',
'num_threads': 128,
'prefix': 'libopenblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.29'}]

Context for the issue:

Found while debugging a crash in the JAX test suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions