-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[BUG] Traceback reference leak in CPython 3.12.0a6 and above #5724
Labels
Milestone
Comments
yut23
added a commit
to yut23/cython
that referenced
this issue
Sep 25, 2023
yut23
added a commit
to yut23/cython
that referenced
this issue
Sep 25, 2023
yut23
added a commit
to yut23/cython
that referenced
this issue
Sep 25, 2023
scoder
pushed a commit
that referenced
this issue
Sep 26, 2023
@scoder Does this issue also apply to Cython 0.29.x and if so, was a fix already released (could not find it in changelog)? |
The issue milestone says 3.0.3, so the fix was (probably) not backported. Looks more like a 3.0.x issue to me. There were a lot of changes in the exception handling code since 0.29.x. It doesn't look like 0.29.x has any special casing code for Py3.12 here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
In CPython 3.12.0a6 and newer with
CYTHON_FAST_THREAD_STATE=1
, traceback objects for Python code called from Cython have their refcounts incremented but never decremented. This is triggered when Cython code calls into a Python function that then raises an exception. The source of the leak is__Pyx_ErrRestoreInState()
, which never callsPy_XDECREF
ontb
:cython/Cython/Utility/Exceptions.c
Lines 178 to 193 in 9827c60
Code to reproduce the behaviour:
lib.pyx:
repro.py:
I've uploaded a full reproducer to https://github.com/yut23/cython_3.12_traceback_leak, along with some code I used to track down the leaks.
Expected behaviour
No response
OS
Linux, macOS
Python version
3.12.0a6+
Cython version
3.0.0+
Additional context
We first encountered this when running yt's test suite on Python 3.12, and reported it to CPython in python/cpython#109602. Thanks to @neutrinoceros, @Xarthisius, and @mdboom for their work in simplifying the reproducer!
I'll make a PR with a proposed fix shortly.
The text was updated successfully, but these errors were encountered: