Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.3k
Closed
Description
Bug report
Bug description:
Summary
Two leak bugs insocketmodule.c triggered whenPySys_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)
importsocket,syssys.addaudithook(lambda*a: (_for_in ()).throw(RuntimeError("audit")))before=sys.gettotalrefcount()foriinrange(1000):try:socket.getaddrinfo("localhost",80)exceptRuntimeError:passafter=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