Skip to content

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 <emanuele.giaquinta@gmail.com>
@exg exg linked an issue Jan 25, 2024 that may be closed by this pull request
@exg exg merged commit e92ac12 into ormsgpack:master Jan 25, 2024
@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