Skip to content

BUG: Hang in StringDType UTF-8 decoder on malformed input. #32287

Description

@fweimer-rh

Describe the issue:

Red Hat Product Security has asked me to forward the attached report upstream.

RHEL-216450.html

Reproduce the code example:

import numpy as np
b = np.array([b"\x80AAAA"], dtype="|S5")
s = b.astype(np.dtypes.StringDType())
np.strings.slice(s, 0, 3, 1)

Error message:

(hang)

Top of GDB backtrace:


slice_strided_loop (context=<optimized out>, data=<optimized out>,              
    dimensions=<optimized out>, strides=<optimized out>, 
    __NPY_UNUSED_TAGGEDauxdata=<optimized out>)
    at ../numpy/_core/src/umath/stringdtype_ufuncs.cpp:2255
2255	                codepoint_offsets.push_back((unsigned char *)inbuf_ptr);
(gdb) bt
#0  slice_strided_loop (context=<optimized out>, data=<optimized out>, 
    dimensions=<optimized out>, strides=<optimized out>, 
    __NPY_UNUSED_TAGGEDauxdata=<optimized out>)
    at ../numpy/_core/src/umath/stringdtype_ufuncs.cpp:2255
#1  0x00007fffe86423b8 in try_trivial_single_output_loop (
    context=0x7fffffffca40, op=0x7fffffffca98, order=NPY_KEEPORDER, 
    errormask=521) at ../numpy/_core/src/umath/ufunc_object.c:982
#2  PyUFunc_GenericFunctionInternal (ufunc=<optimized out>, 
    ufuncimpl=<optimized out>, operation_descrs=0x7fffffffcaf0, 
    op=0x7fffffffca98, casting=NPY_SAME_KIND_CASTING, order=NPY_KEEPORDER, 
    wheremask=<optimized out>) at ../numpy/_core/src/umath/ufunc_object.c:2248
#3  ufunc_generic_fastcall (ufunc=<optimized out>, args=<optimized out>, 
    len_args=<optimized out>, kwnames=<optimized out>, outer=<optimized out>)
    at ../numpy/_core/src/umath/ufunc_object.c:4723

Python and NumPy Versions:

Python 3.14.6 running numpy 2.4.6

Runtime Environment:

No response

How does this issue affect you or how did you find it:

I've been advised to include this message: Found by AISLE in partnership with Red Hat

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions