Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Importing numpy 2.2.6 for Python 3.12.10, GCC 11.4.0 on linux throws a segmentation fault #29075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vtomole opened this issue May 28, 2025 · 6 comments
Labels

Comments

@vtomole
Copy link

vtomole commented May 28, 2025

Describe the issue:

pip installing numpy on Ubuntu 22.04.5 LTS and attempting to import it raises a segmentation fault.

Reproduce the code example:

$ python3.12 -m venv .venv
$ source .venv/bin/activate
$ pip install numpy==2.2.6
$ python -c "import numpy"

Error message:

Segmentation fault (core dumped)

Python and NumPy Versions:

Importing numpy segfaults but the system version is 3.12.10 (main, Apr 9 2025, 08:55:05) [GCC 11.4.0]

Runtime Environment:

No response

Context for the issue:

Got caught from a downstream library that imports numpy quantumlib/Stim#957. Maybe this is related to #28991

@mattip
Copy link
Member

mattip commented May 28, 2025

What platform hardware are you using? Is this inside a VM, and if so which one?

@ngoldbaum
Copy link
Member

Can you get a traceback for the segfault from e.g. gdb?

@vtomole
Copy link
Author

vtomole commented May 28, 2025

What platform hardware are you using? Is this inside a VM, and if so which one?

I'm not on a VM. here are my specs:

Image

@ngoldbaum
Copy link
Member

ngoldbaum commented May 28, 2025

I have an older Dell XPS 13 9380 with a Core i7-8565U CPU running Ubuntu 22.04.5 LTS and I'm not able to reproduce the segfault using Python 3.12.10 installed via pyenv.

@vtomole
Copy link
Author

vtomole commented May 28, 2025

Can you get a traceback for the segfault from e.g. gdb?

GDB is telling me that ctypes is what's causing the problem. I built a fresh install of Python 3.12.10 from source and this problem is gone now. Is this issue still worth leaving open?

Here are the GDB logs by the way

(venv) victory@victory-xps-15-9520:~/test$ gdb --args python -c "import numpy" GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: .

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...
(No debugging symbols found in python)
(gdb) run
Starting program: /home/victory/test/venv/bin/python -c import\ numpy
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffd43ff640 (LWP 1304019)]
[New Thread 0x7fffd3bfe640 (LWP 1304020)]
[New Thread 0x7fffd33fd640 (LWP 1304021)]
[New Thread 0x7fffd2bfc640 (LWP 1304022)]
[New Thread 0x7fffd23fb640 (LWP 1304023)]
[New Thread 0x7fffd1bfa640 (LWP 1304024)]
[New Thread 0x7fffd13f9640 (LWP 1304025)]
[New Thread 0x7fffd0bf8640 (LWP 1304026)]
[New Thread 0x7fffd03f7640 (LWP 1304027)]
[New Thread 0x7fffcfbf6640 (LWP 1304028)]
[New Thread 0x7fffcf3f5640 (LWP 1304029)]
[New Thread 0x7fffcebf4640 (LWP 1304030)]
[New Thread 0x7fffce3f3640 (LWP 1304031)]
[New Thread 0x7fffcdbf2640 (LWP 1304032)]
[New Thread 0x7fffcd3f1640 (LWP 1304033)]

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x0000000000561337 in _PyObject_LookupAttr ()
(gdb) bt
#0 0x0000000000561337 in _PyObject_LookupAttr ()
#1 0x00007ffff73f1453 in ?? () from /usr/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so
#2 0x000000000053d2d7 in _PyObject_MakeTpCall ()
#3 0x000000000061e9c4 in ?? ()
#4 0x00000000005605cc in ?? ()
#5 0x00000000005604c6 in PyObject_Vectorcall ()
#6 0x0000000000548140 in _PyEval_EvalFrameDefault ()
#7 0x000000000061d5b9 in PyEval_EvalCode ()
#8 0x000000000063bd0c in ?? ()
#9 0x00000000005605cc in ?? ()
#10 0x000000000054c992 in _PyEval_EvalFrameDefault ()
#11 0x000000000056a9ad in ?? ()
#12 0x0000000000597021 in PyObject_CallMethodObjArgs ()
#13 0x0000000000595c4c in PyImport_ImportModuleLevelObject ()
#14 0x000000000054f4d5 in _PyEval_EvalFrameDefault ()
#15 0x000000000061d5b9 in PyEval_EvalCode ()
#16 0x000000000063bd0c in ?? ()
#17 0x00000000005605cc in ?? ()
#18 0x000000000054c992 in _PyEval_EvalFrameDefault ()
#19 0x000000000056a9ad in ?? ()
#20 0x0000000000597021 in PyObject_CallMethodObjArgs ()
#21 0x0000000000595c4c in PyImport_ImportModuleLevelObject ()
#22 0x00000000005a76b3 in ?? ()
#23 0x00000000005605cc in ?? ()
#24 0x000000000054c992 in _PyEval_EvalFrameDefault ()
#25 0x000000000056a9ad in ?? ()
#26 0x0000000000597021 in PyObject_CallMethodObjArgs ()
#27 0x0000000000595d52 in PyImport_ImportModuleLevelObject ()
#28 0x000000000054f4d5 in _PyEval_EvalFrameDefault ()
#29 0x000000000061d5b9 in PyEval_EvalCode ()
#30 0x000000000063bd0c in ?? ()
#31 0x00000000005605cc in ?? ()
#32 0x000000000054c992 in _PyEval_EvalFrameDefault ()
#33 0x000000000056a9ad in ?? ()
#34 0x0000000000597021 in PyObject_CallMethodObjArgs ()
#35 0x0000000000595c4c in PyImport_ImportModuleLevelObject ()
#36 0x00000000005a76b3 in ?? ()
#37 0x00000000005605cc in ?? ()
#38 0x000000000054c992 in _PyEval_EvalFrameDefault ()
#39 0x000000000056a9ad in ?? ()
#40 0x0000000000597021 in PyObject_CallMethodObjArgs ()
#41 0x0000000000595c4c in PyImport_ImportModuleLevelObject ()
#42 0x000000000054f4d5 in _PyEval_EvalFrameDefault ()
#43 0x000000000061d5b9 in PyEval_EvalCode ()
#44 0x000000000063bd0c in ?? ()
#45 0x00000000005605cc in ?? ()
#46 0x000000000054c992 in _PyEval_EvalFrameDefault ()
#47 0x000000000056a9ad in ?? ()
#48 0x0000000000597021 in PyObject_CallMethodObjArgs ()
#49 0x0000000000595c4c in PyImport_ImportModuleLevelObject ()
#50 0x000000000054f4d5 in _PyEval_EvalFrameDefault ()
#51 0x000000000061d5b9 in PyEval_EvalCode ()
#52 0x000000000063bd0c in ?? ()
#53 0x00000000005605cc in ?? ()
#54 0x000000000054c992 in _PyEval_EvalFrameDefault ()
#55 0x000000000056a9ad in ?? ()
#56 0x0000000000597021 in PyObject_CallMethodObjArgs ()
#57 0x0000000000595c4c in PyImport_ImportModuleLevelObject ()
#58 0x000000000054f4d5 in _PyEval_EvalFrameDefault ()
--Type for more, q to quit, c to continue without paging--
#59 0x000000000061d5b9 in PyEval_EvalCode ()
#60 0x00000000006591db in ?? ()
#61 0x0000000000654346 in ?? ()
#62 0x00000000006503b3 in PyRun_StringFlags ()
#63 0x00000000006500be in PyRun_SimpleStringFlags ()
#64 0x000000000064d622 in Py_RunMain ()
#65 0x00000000006064ad in Py_BytesMain ()
#66 0x00007ffff7c29d90 in __libc_start_call_main (main=main@entry=0x6063f0, argc=argc@entry=3, argv=argv@entry=0x7fffffffdef8) at ../sysdeps/nptl/libc_start_call_main.h:58
#67 0x00007ffff7c29e40 in __libc_start_main_impl (main=0x6063f0, argc=3, argv=0x7fffffffdef8, init=, fini=, rtld_fini=, stack_end=0x7fffffffdee8)
at ../csu/libc-start.c:392
#68 0x0000000000606325 in _start ()

@mattip
Copy link
Member

mattip commented May 29, 2025

Where did the failing CPython build come from? I see 3.12.10 (main, Apr 9 2025, 08:55:05) [GCC 11.4.0]

@jorenham jorenham changed the title BUG: Importing numpy 2.6.6 for Python 3.12.10, GCC 11.4.0 on linux throws a segmentation fault BUG: Importing numpy 2.2.6 for Python 3.12.10, GCC 11.4.0 on linux throws a segmentation fault May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants