-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Description
Describe the issue:
np.isin()
segfaults when passed 10918 or more elements of a MSB unsigned integer type with any negative-valued test elements.
Reproduce the code example:
import numpy as np
np.isin(np.zeros(10918, dtype='>u4'), [-1])
Error message:
#0 0x00000000ffffffff in ?? ()
#1 0x00007ffff71b1455 in execute_ufunc_loop (
context=context@entry=0x7fffffffaef0, masked=masked@entry=0,
op=op@entry=0x7fffffffaf28, order=order@entry=NPY_KEEPORDER,
buffersize=<optimized out>, casting=casting@entry=NPY_SAME_KIND_CASTING,
op_flags=0x7fffffffafc0, errormask=521)
at ../numpy/_core/src/umath/ufunc_object.c:1169
#2 0x00007ffff71ba20a in PyUFunc_GenericFunctionInternal (
wheremask=<optimized out>, order=NPY_KEEPORDER,
casting=NPY_SAME_KIND_CASTING, op=0x7fffffffaf28,
operation_descrs=0x7fffffffaf60, ufuncimpl=<optimized out>,
ufunc=0x7ffff7381240) at ../numpy/_core/src/umath/ufunc_object.c:2244
#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:4524
#4 0x0000555555778286 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=2,
args=0x7fffffffb530, callable=<numpy.ufunc at remote 0x7ffff7381240>,
tstate=0x555555be2e50 <_PyRuntime+458992>)
at /usr/local/src/conda/python-3.12.8/Include/internal/pycore_call.h:92
#5 object_vacall (tstate=0x555555be2e50 <_PyRuntime+458992>,
base=base@entry=0x0, callable=<numpy.ufunc at remote 0x7ffff7381240>,
vargs=vargs@entry=0x7fffffffb5a0)
at /usr/local/src/conda/python-3.12.8/Objects/call.c:850
#6 0x0000555555810a58 in PyObject_CallFunctionObjArgs (
callable=<optimized out>)
at /usr/local/src/conda/python-3.12.8/Objects/call.c:957
#7 0x0000555555782f28 in do_richcompare (op=1, w=-1,
v=<numpy.ndarray at remote 0x7fff5331ddd0>,
tstate=0x555555be2e50 <_PyRuntime+458992>)
at /usr/local/src/conda/python-3.12.8/Objects/object.c:816
#8 PyObject_RichCompare (v=v@entry=<numpy.ndarray at remote 0x7fff5331ddd0>,
w=w@entry=-1, op=1)
at /usr/local/src/conda/python-3.12.8/Objects/object.c:865
#9 0x000055555566c55a in _PyEval_EvalFrameDefault (tstate=<optimized out>,
frame=0x7ffff7fb0140, throwflag=<optimized out>) at Python/bytecodes.c:2045
#10 0x000055555576d1ae in _PyObject_VectorcallTstate (kwnames=<optimized out>,
nargsf=<optimized out>, args=<optimized out>,
callable=<function at remote 0x7fff53314ae0>,
tstate=0x555555be2e50 <_PyRuntime+458992>)
at /usr/local/src/conda/python-3.12.8/Include/internal/pycore_call.h:92
#11 PyObject_Vectorcall (callable=<function at remote 0x7fff53314ae0>,
args=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>)
at /usr/local/src/conda/python-3.12.8/Objects/call.c:325
#12 0x00007ffff70ce3e4 in dispatcher_vectorcall (self=0x7fff5330a0f0,
#13 0x000055555576d1ae in _PyObject_VectorcallTstate (kwnames=<optimized out>,
nargsf=<optimized out>, args=<optimized out>,
callable=<numpy._ArrayFunctionDispatcher at remote 0x7fff5330a0f0>,
tstate=0x555555be2e50 <_PyRuntime+458992>)
at /usr/local/src/conda/python-3.12.8/Include/internal/pycore_call.h:92
#14 PyObject_Vectorcall (
callable=<numpy._ArrayFunctionDispatcher at remote 0x7fff5330a0f0>,
args=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>)
at /usr/local/src/conda/python-3.12.8/Objects/call.c:325
#15 0x00005555556666a1 in _PyEval_EvalFrameDefault (tstate=<optimized out>,
frame=0x7ffff7fb0020, throwflag=<optimized out>) at Python/bytecodes.c:2715
#16 0x000055555580e741 in PyEval_EvalCode (
co=co@entry=<code at remote 0x7ffff7565110>,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>})
at /usr/local/src/conda/python-3.12.8/Python/ceval.c:578
#17 0x0000555555832f1a in run_eval_code_obj (
tstate=tstate@entry=0x555555be2e50 <_PyRuntime+458992>,
co=co@entry=0x7ffff7565110,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>})
at /usr/local/src/conda/python-3.12.8/Python/pythonrun.c:1722
#14 PyObject_Vectorcall (
callable=<numpy._ArrayFunctionDispatcher at remote 0x7fff5330a0f0>,
args=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>)
at /usr/local/src/conda/python-3.12.8/Objects/call.c:325
#15 0x00005555556666a1 in _PyEval_EvalFrameDefault (tstate=<optimized out>,
frame=0x7ffff7fb0020, throwflag=<optimized out>) at Python/bytecodes.c:2715
#16 0x000055555580e741 in PyEval_EvalCode (
co=co@entry=<code at remote 0x7ffff7565110>,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>})
at /usr/local/src/conda/python-3.12.8/Python/ceval.c:578
#17 0x0000555555832f1a in run_eval_code_obj (
tstate=tstate@entry=0x555555be2e50 <_PyRuntime+458992>,
co=co@entry=0x7ffff7565110,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>})
at /usr/local/src/conda/python-3.12.8/Python/pythonrun.c:1722
--Type <RET> for more, q to quit, c to continue without paging--
#18 0x000055555582dd35 in run_mod (mod=mod@entry=0x555555c853b0,
filename=filename@entry='/home/michael/Desktop/numpy/../pdr/min.py',
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>}, flags=flags@entry=0x7fffffffc130,
arena=arena@entry=0x7ffff751bcb0)
at /usr/local/src/conda/python-3.12.8/Python/pythonrun.c:1743
#19 0x0000555555846780 in pyrun_file (fp=fp@entry=0x555555c20ea0,
filename=filename@entry='/home/michael/Desktop/numpy/../pdr/min.py',
start=start@entry=257,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/michael/Desktop/numpy/../pdr/min.py') at remote 0x7ffff75f8d40>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff759c270>, '__file__': '/home/michael/Desktop/numpy/../pdr/min.py', '__cached__': None, 'np': <module at remote 0x7ffff743d7b0>}, closeit=closeit@entry=1, flags=0x7fffffffc130)
at /usr/local/src/conda/python-3.12.8/Python/pythonrun.c:1643
#20 0x0000555555845dfe in _PyRun_SimpleFileObject (fp=0x555555c20ea0,
filename='/home/michael/Desktop/numpy/../pdr/min.py', closeit=1,
flags=0x7fffffffc130)
at /usr/local/src/conda/python-3.12.8/Python/pythonrun.c:433
#21 0x0000555555845ac4 in _PyRun_AnyFileObject (fp=0x555555c20ea0,
filename=filename@entry='/home/michael/Desktop/numpy/../pdr/min.py',
closeit=closeit@entry=1, flags=flags@entry=0x7fffffffc130)
at /usr/local/src/conda/python-3.12.8/Python/pythonrun.c:78
#22 0x000055555583edfe in pymain_run_file_obj (skip_source_first_line=0,
filename='/home/michael/Desktop/numpy/../pdr/min.py',
program_name='/opt/mambaforge/envs/numpy-dev/bin/python3.12')
at /usr/local/src/conda/python-3.12.8/Modules/main.c:360
#23 pymain_run_file (config=0x555555b85a30 <_PyRuntime+77008>)
at /usr/local/src/conda/python-3.12.8/Modules/main.c:379
#24 pymain_run_python (exitcode=0x7fffffffc104)
at /usr/local/src/conda/python-3.12.8/Modules/main.c:633
#25 Py_RunMain () at /usr/local/src/conda/python-3.12.8/Modules/main.c:713
#26 0x00005555557f90c7 in Py_BytesMain (argc=<optimized out>,
argv=<optimized out>)
at /usr/local/src/conda/python-3.12.8/Modules/main.c:767
#27 0x00007ffff7c29d90 in __libc_start_call_main (
main=main@entry=0x5555557f9010 <main>, argc=argc@entry=2,
argv=argv@entry=0x7fffffffc388)
at ../sysdeps/nptl/libc_start_call_main.h:58
#28 0x00007ffff7c29e40 in __libc_start_main_impl (main=0x5555557f9010 <main>,
argc=2, argv=0x7fffffffc388, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffc378)
at ../csu/libc-start.c:392
#29 0x00005555557f8f71 in _start ()
Python and NumPy Versions:
python: 3.12.8
numpy: 2.2.1
Runtime Environment:
[{'numpy_version': '2.2.1',
'python': '3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:24:40) '
'[GCC 13.3.0]',
'uname': uname_result(system='Linux', node='indirection', release='6.9.3-76060903-generic', version='#202405300957173214176822.04~f2697e1 SMP PREEMPT_DYNAMIC Wed N', 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',
Context for the issue:
I work with legacy scientific data, and regularly need to run checks against arrays of arbitrary dtype. More generally, the high-level API should not segfault.