-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Open
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
If a heap type does not have Py_TPFLAGS_HAVE_GC or doesn't not implement tp_traverse, the garbage collector may fail to collect the type and most of its instances at Python exit. The problem is worse when sub-interpreters are involved: if a sub-interpreter exits and does not clear all of its memory, the other interpreters will continue running with these leaks.
See issue gh-87138 for the rationale.
I wrote an article on the lock type which had this bug and caused a memory leak: https://vstinner.github.io/subinterpreter-leaks.html
Linked PRs
- [draft] gh-116946: Emit RuntimeError if a heap type does not implement traverse #116947
- gh-116946: fully implement GC protocol for
zlib
objects #138290 - [3.14] gh-116946: fully implement GC protocol for
zlib
objects (GH-138290) #138327 - [3.13] gh-116946: fully implement GC protocol for
zlib
objects (GH-138290) #138328 - gh-116946: fully implement GC protocol for
_tkinter
objects #138331 - gh-116946: fully implement GC protocol for
_curses_panel.panel
#138333 - [3.14] gh-116946: fully implement GC protocol for
_curses_panel.panel
(GH-138333) #138427 - [3.13] gh-116946: fully implement GC protocol for
_curses_panel.panel
(GH-138333) #138428 - gh-116946: fully implement GC protocol for
_functools._lru_list_elem
#138334 - gh-116946: add
Py_TPFLAGS_IMMUTABLETYPE
toselect.[e]poll
#138340 - gh-116946: add
Py_TPFLAGS_IMMUTABLETYPE
to_random.Random
#138341
The following PRs were directly closed because the types are immutable and empty:
- gh-116946: fully implement GC protocol for
_thread._localdummy
#138329 - gh-116946: fully implement GC protocol for
_tokenize.TokenizerIter
#138330 - gh-116946: fully implement GC protocol for
_ssl.Certificate
#138332
The following PRs were wrongly merged so we reverted them:
- gh-116946: fully implement GC protocol for
bz2
objects #138266 - [3.14] gh-116946: fully implement GC protocol for
bz2
objects (GH-138266) #138320 - [3.13] gh-116946: fully implement GC protocol for
bz2
objects (GH-138266) #138322 - gh-116946: fully implement GC protocol for
lzma
objects #138288 - [3.14] gh-116946: fully implement GC protocol for
lzma
objects (GH-138288) #138321 - [3.13] gh-116946: fully implement GC protocol for
lzma
objects (GH-138288) #138323 - gh-116946: fully implement GC protocol for
_hashlib
objects #138289 - [3.14] gh-116946: fully implement GC protocol for
_hashlib
objects (GH-138289) #138324 - [3.13] gh-116946: fully implement GC protocol for
_hashlib
objects (GH-138289) #138326
PRs for reverting the above commits:
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error