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

Segmentation fault with simple code and Python 3.11 #223

Closed
vincbo opened this issue Jan 23, 2024 · 1 comment · Fixed by #224
Closed

Segmentation fault with simple code and Python 3.11 #223

vincbo opened this issue Jan 23, 2024 · 1 comment · Fixed by #224

Comments

@vincbo
Copy link

vincbo commented Jan 23, 2024

The following code

import ormsgpack

ormsgpack.packb("hello")

leads to a segmentation fault on the following configurations:

ormsgpack 1.4.1 + Python 3.11.7 on Debian 12
ormsgpack 1.4.1 + Python 3.11.6 on macOS sonoma 14.2.1

To reproduce, copy the content in file called test.py for example and execute the command:

python3 test.py

The example works fine with Python 3.9.16 and Python 3.10.10.

@vincbo vincbo changed the title Segmentation fault with simple packb/unpackb round-trip code Segmentation fault with simple code and Python 3.11 Jan 23, 2024
@exg
Copy link
Collaborator

exg commented Jan 24, 2024

Thanks for the report. I opened a pull request to fix the issue.

@exg exg linked a pull request Jan 25, 2024 that will close this issue
@exg exg closed this as completed in #224 Jan 25, 2024
exg added a commit that referenced this issue Jan 25, 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.

Signed-off-by: Emanuele Giaquinta <[email protected]>
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 a pull request may close this issue.

2 participants