You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Reference leak in _asyncio_Task___init___impl in _asynciomodule.c #126083
I discovered this while working on #126080. If the func is given a context that isn't None, instead of doing Py_XSETREF it'll just do a regular assignment meaning that whatever was there before wont have its reference count decreased.
importasyncioimportsys# for convenience so I dont have to set up everything else for a Task obj# and can just focus on the ref leakclassBreak:
def__str__(self):
raiseException("break")
asyncdefcoro():
passtask=asyncio.Task.__new__(asyncio.Task)
co=coro()
obj=object()
print("refcount before bug", sys.getrefcount(obj))
for_inrange(10000):
try:
task.__init__(co, context=obj, name=Break())
except: passprint("refcount after bug", sys.getrefcount(obj))
Activity
sobolevn commentedon Oct 28, 2024
Yes,
Py_XSETREFseems like a good solution here. @Nico-Posada, please send a PR :)gh-126083: Fix a reference leak in `asyncio.Task` when reinitializing…
pythongh-126083: Fix a reference leak in `asyncio.Task` when reinitia…
pythongh-126083: Fix a reference leak in `asyncio.Task` when reinitia…
[3.13] gh-126083: Fix a reference leak in `asyncio.Task` when reiniti…
[3.12] gh-126083: Fix a reference leak in `asyncio.Task` when reiniti…
pythongh-126083: Fix a reference leak in `asyncio.Task` when reinitia…
pythongh-126083: Fix a reference leak in `asyncio.Task` when reinitia…