Skip to content

BUG: some ufuncs return NULL without setting an error when stride >= 2**31 elements and SIMD optimizations enabled #20921

@jmuhlich

Description

@jmuhlich

Describe the issue:

Since SIMD optimizations were introduced, some ufuncs such as max and min raise SystemError: <built-in method reduce of numpy.ufunc object at ...> returned NULL without setting an error if the inner loop stride is 2**31 elements or greater.

Reproduce the code example:

# Requires 2+ GB of RAM.
import numpy as np
a = np.zeros((2, 2**31), 'uint8')
a.max(axis=0)

Error message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File ".../numpy/core/_methods.py", line 40, in _amax
    return umr_maximum(a, axis, None, out, keepdims, initial, where)
SystemError: <built-in method reduce of numpy.ufunc object at 0x7fd1c5787540> returned NULL without setting an error

NumPy/Python version information:

Tested on both x86_64 and arm64:

cp38-cp38-manylinux2014_x86_64
1.22.1 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0]

cp310-cp310-macosx_11_0_arm64
1.22.1 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions