-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Closed
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
- gh-146245: Fix ref/buffer leaks in socketmodule.c on audit hook failure #146247
- gh-146245: Fix reference and buffer leaks via audit hook in socket module #146248
- [3.14] gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) #146274
- [3.13] gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) #146275
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