-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Python (debug mode+free threading) segfaults at exit since Numpy 2.2.0 #27953
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
Comments
I'm not able to reproduce this on a fresh build debug build of python 3.13.1t and numpy built from source from main or with the numpy 2.2.0 wheel on pypi on my ARM macbook Pro:
Trying on Linux next... |
I later updated the issue, it seems you also need the debug mode enabled. |
I built Python with debug mode. |
It would help me if you could give more information about how you're installing numpy after building python. |
I can't reproduce this on an amd64 Ubuntu 22.04 system either, using either a from-source numpy build or the 2.2.0 wheel. |
2.2.0:
2.1.3:
|
Oh interesting, it looks like I do get a seg fault when Python exits:
|
What changed on your side, |
Thanks for this tip! |
I was trying to prove that I don't hit the segfault on my machine, and I've only hit it doing exactly what I copy/pasted. |
Is it 100% reproducible or just once in a while? |
I was able to trigger it on NumPy 2.2.0 but not on NumPy main, so I suspect a broken backport is the cause. Ping @charris. Here's the traceback in a debug build of NumPy 2.2.0:
|
Is there anything I can do to help? I'll later try with a numpy built from source. |
No I think this should be sorted out quickly and we'll do a 2.2.1 release with a fix. |
Thank you for the lightning support! |
I edited some of my comments above, there is a |
ping @seberg do you have any idea why we'd seg fault in the destructor of a |
Oh I see, this is a very dumb use-after-free error: numpy/numpy/_core/src/common/npy_hashtable.cpp Lines 129 to 132 in ba9205f
Those two operations should be switched. Oops! PR incoming... |
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
Numpy 2.1.3 works fine but with 2.2.0 the interpreter segfaults at exit.
Both Python 3.13.0t and 3.13.1t segfault at exit, both 3.13.0 and 3.13.1 do not.
I can reproduce this on macOS (amd64), Debian 11 (amd64) and Debian 12 (arm64). However also other combinations might be affected.
All the interpreters are built in debug mode with pyenv, ex.
pyenv install -g 3.13.1t
.Did not check if non-debug builds are affected as well.Python 3.13.1t non-debug (pyenv install 3.13.1t
), at least on macOS, does not exhibit the segfault.The discriminating Python build options seem to be:
Reproduce the code example:
Error message (from gdb on Debian 12 arm64):
Python and NumPy Versions:
3.13.1 experimental free-threading build (main, Dec 9 2024, 11:53:27) [Clang 16.0.0 (clang-1600.0.26.4)]
2.2.0
Context for the issue:
This affects the Pygolo Project CI pipeline (logs) which has a minimal interoperability extension test based on Numpy. I will pin the release of Numpy so to use 2.1.3 but I'll be happy to revert that as soon as this bug is fixed.
The text was updated successfully, but these errors were encountered: