Skip to content

NumPy crash that only happens with uv's Python 3.14 on Linux #991

@ngoldbaum

Description

@ngoldbaum

See numpy/numpy#30899 (comment) for full context.

If I set up a new Python environment with uv's Python build and run a NumPy script that triggers NumPy's temporary elision codepaths, I get a segfault inside of the backtrace C function provided by libunwind (although the segfault is in libgcc).

uv venv .venv314 --python 3.14
source .venv314/bin/activate
uv pip install numpy
python test.py

Where test.py has the following content:

import numpy as np
d = np.random.rand(512, 512).astype(np.float32)
condition = False
condition |= d == np.float32(65534.0)

The traceback from gdb:

(gdb) r test.py
Starting program: /home/goldbaum/.venv314/bin/python test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff78cba10 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
(gdb) bt
#0  0x00007ffff78cba10 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#1  0x00007ffff78cd91e in _Unwind_Backtrace () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#2  0x00007ffff7d35eb3 in __GI___backtrace (array=<optimized out>, size=10) at ./debug/backtrace.c:78
#3  0x00007ffff6d39948 in check_callers (cannot=0x7fffffffcf54) at ../numpy/_core/src/multiarray/temp_elide.c:171
#4  0x00007ffff6d3a2b5 in can_elide_temp (olhs=0x7ffff628a1f0, orhs=0x152b7b8 <_Py_FalseStruct>, cannot=0x7fffffffcf54)
    at ../numpy/_core/src/multiarray/temp_elide.c:347
#5  0x00007ffff6d3a3a4 in try_binary_elide (m1=0x152b7b8 <_Py_FalseStruct>, m2=0x7ffff628a1f0,
    inplace_op=0x7ffff6d23cc8 <array_inplace_bitwise_or>, res=0x7fffffffcf88, commutative=1)
    at ../numpy/_core/src/multiarray/temp_elide.c:373
#6  0x00007ffff6d23568 in array_bitwise_or (m1=0x152b7b8 <_Py_FalseStruct>, m2=0x7ffff628a1f0)
    at ../numpy/_core/src/multiarray/number.c:491
#7  0x0000000001ada90f in PyNumber_InPlaceOr.warm ()
#8  0x0000000000000014 in ?? ()
#9  0x0000000000000014 in ?? ()
#10 0x00007ffff7e16020 in ?? ()
#11 0x000000000152b7b9 in _Py_FalseStruct ()
#12 0x00007ffff7a6672e in ?? ()
#13 0x0000000001801394 in _TAIL_CALL_BINARY_OP.llvm.10362591704542007599 ()
#14 0x00000000018890ed in _PyEval_Vector ()
#15 0x0000000001888de7 in PyEval_EvalCode ()
#16 0x00000000018e4c73 in run_mod.llvm ()
#17 0x0000000001a3b9c7 in pyrun_file ()
#18 0x0000000001a3979b in _PyRun_SimpleFileObject ()
#19 0x0000000001a39682 in _PyRun_AnyFileObject ()
#20 0x0000000001a391f6 in pymain_run_file_obj ()
#21 0x0000000001a390f4 in pymain_run_file ()
#22 0x00000000019b0f91 in Py_RunMain ()
#23 0x00000000019ae9c3 in pymain_main.llvm ()
#24 0x00000000019ae7ad in main ()

See the linked NumPy issue for some vague speculation from me about why this is happening.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions