-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
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
Bug report
Bug description:
Summary
Two leak bugs in socketmodule.c triggered when PySys_Audit raises:
getaddrinfo(line 6983):idnaand/orpstrrefs leaked when audit hook raises. ~657 objects leaked per 1000 calls.sock_sendto(line 4810):pbufPy_buffer not released when audit hook raises.
Reproducer (getaddrinfo leak)
import socket, sys
sys.addaudithook(lambda *a: (_ for _ in ()).throw(RuntimeError("audit")))
before = sys.gettotalrefcount()
for i in range(1000):
try:
socket.getaddrinfo("localhost", 80)
except RuntimeError:
pass
after = sys.gettotalrefcount()
print(f"Leaked {after - before} objects in 1000 calls")CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Reactions are currently unavailable
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