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

bpo-42972: _thread.RLock type implements tp_traverse #26734

Merged
merged 1 commit into from Jun 15, 2021

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Jun 15, 2021

The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the the Py_TPFLAGS_HAVE_GC flag.

https://bugs.python.org/issue42972

@vstinner
Copy link
Member Author

@vstinner vstinner commented Jun 15, 2021

Leak discovered by #26727

The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the Py_TPFLAGS_HAVE_GC flag.
@pitrou
Copy link
Member

@pitrou pitrou commented Jun 15, 2021

Don't we have a warning for when heap types don't implement a tp_traverse?

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Jun 15, 2021

Don't we have a warning for when heap types don't implement a tp_traverse?

No, the warning is when a heap type has the GC flags but don't have tp_traverse. in this case we were missing the GC flags so the check failed to raise the warning

@vstinner
Copy link
Member Author

@vstinner vstinner commented Jun 15, 2021

Don't we have a warning for when heap types don't implement a tp_traverse?

I agree that a warning should be emitted at runtime when a heap type doesn't have the Py_TPFLAGS_HAVE_GC or doesn't implement tp_traverse. I suggest to discuss this idea in https://bugs.python.org/issue42972

It's super hard to discover such very tricky bug if you don't have a very deep understanding of GC internals and how Python works.

Copy link
Member

@shihai1991 shihai1991 left a comment

LGTM.

@vstinner vstinner merged commit 1cd3d85 into python:main Jun 15, 2021
12 of 13 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jun 15, 2021

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒🤖

@vstinner vstinner deleted the rlock_traverse branch Jun 15, 2021
miss-islington added a commit to miss-islington/cpython that referenced this issue Jun 15, 2021
The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the Py_TPFLAGS_HAVE_GC flag.
(cherry picked from commit 1cd3d85)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jun 15, 2021

GH-26735 is a backport of this pull request to the 3.10 branch.

miss-islington added a commit that referenced this issue Jun 15, 2021
The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the Py_TPFLAGS_HAVE_GC flag.
(cherry picked from commit 1cd3d85)

Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner
Copy link
Member Author

@vstinner vstinner commented Jun 15, 2021

Thanks for your reviews @pablogsal and @shihai1991 ;-)

jdevries3133 added a commit to jdevries3133/cpython that referenced this issue Jun 19, 2021
The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the Py_TPFLAGS_HAVE_GC flag.
JuniorJPDJ added a commit to JuniorJPDJ/cpython that referenced this issue Aug 12, 2021
The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the Py_TPFLAGS_HAVE_GC flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants