Skip to content
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

Fix crash with python 3.11 (#223) #224

Merged
merged 1 commit into from
Jan 25, 2024
Merged

Fix crash with python 3.11 (#223) #224

merged 1 commit into from
Jan 25, 2024

Conversation

exg
Copy link
Collaborator

@exg exg commented Jan 24, 2024

We borrow a reference to the static exceptions TypeError and ValueError and pass these objects to PyModule_AddObject, which steals a reference. In Python 3.11 and newer, Py_Finalize() deallocates static exceptions

python/cpython#30805

This results in a crash on termination, because _PyStaticType_Dealloc indirectly calls _Py_Dealloc on the objects as the reference count drops to zero. The issue does not occur in Python 3.12 and newer because the objects are immortal.

We borrow a reference to the static exceptions TypeError and
ValueError and pass these objects to PyModule_AddObject, which steals
a reference. In Python 3.11 and newer, Py_Finalize() deallocates
static exceptions

python/cpython#30805

This results in a crash on termination, because _PyStaticType_Dealloc
indirectly calls _Py_Dealloc on the objects as the reference count
drops to zero. The issue does not occur in Python 3.12 and newer
because the objects are immortal.

Signed-off-by: Emanuele Giaquinta <[email protected]>
@exg exg linked an issue Jan 25, 2024 that may be closed by this pull request
@exg exg merged commit e92ac12 into aviramha:master Jan 25, 2024
34 checks passed
@exg exg deleted the maint branch January 25, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation fault with simple code and Python 3.11
1 participant