Repository navigation
gh-116915: Make _thread._ThreadHandle support GC - #116934
Conversation
Even though it has no internal references to Python objects it still has a reference to its type by virtue of being a heap type. We need to provide a traverse function that visits the type, but we do not need to provide a clear function.
|
Would a fix that only decrefs the type in dealloc be sufficient, without supporting GC? That could save some GC cycles. https://docs.python.org/3/c-api/typeobj.html#c.Py_TPFLAGS_HEAPTYPE |
Unfortunately, no. That decref was already present. |
|
The |
|
🤖 New build scheduled with the buildbot fleet by @colesbury for commit 2ef088d 🤖 If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
Huh that's really strange. Usually cycles between types and the object itself are special. Will think about this. |
|
Ah right I forgot that heap types need to support GC as well. This can be seen in previous work. In this case, this LGTM. |
pitrou
left a comment
There was a problem hiding this comment.
+1. Let's wait for the refleaks builders to be become green again and then merge this.
Fidget-Spinner
left a comment
There was a problem hiding this comment.
It seems there is indeed a reference cycle between heap types and the module object itself
Line 4557 in 2982bdb
|
Windows 11: https://buildbot.python.org/all/#/builders/1214/builds/304/steps/4/logs/stdio
cpython/Lib/test/test_threading.py Lines 424 to 459 in 2982bdb |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I looked at my checkbox: https://pythondev.readthedocs.io/subinterpreters.html#convert-static-type-to-heap-type
|
@colesbury: I cannot reproduce the crash on Windows 11. I stressed the test:
I tried for 15-20 minutes, without reproducing the crash :-( |
|
Nice fix @mpage. I confirm that it does fix the leak: #116915 (comment) |
|
If anyone see the test_threading.test_finalize_running_thread() crash again, please open a new issue. |
Even though it has no internal references to Python objects it still has a reference to its type by virtue of being a heap type. We need to provide a traverse function that visits the type, but we do not need to provide a clear function.
Even though it has no internal references to Python objects it still has a reference to its type by virtue of being a heap type. We need to provide a traverse function that visits the type, but we do not need to provide a clear function.
Even though it has no internal references to Python objects it still has a reference to its type by virtue of being a heap type. We need to provide a traverse function that visits the type, but we do not need to provide a clear function.
Even though it has no internal references to Python objects it still has a reference to its type by virtue of being a heap type. We need to provide a traverse function that visits the type, but we do not need to provide a clear function.
test_capileaks references #116915