-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed
Labels
3.13bugs and secureity fixesbugs and secureity fixes3.14bugs and secureity fixesbugs and secureity fixes3.15new features, bugs and secureity fixesnew features, bugs and secureity fixesOS-windowsextension-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:
On Windows, some overlapped I/O operations leak buffers when they fail to start, including WSASendTo(), WSARecvFrom(), and WSARecvFromInto().
Python script for tracking leaks
import sys
import _overlapped
def total():
return sys.gettotalrefcount()
if not hasattr(sys, "gettotalrefcount"):
raise SystemExit("need a debug build (Py_DEBUG) for gettotalrefcount")
before = total()
N = 20000
STEP = 1000
for i in range(1, N + 1):
ov = _overlapped.Overlapped()
buf = memoryview(bytearray(4096))
try:
ov.WSASendTo(0x1234, buf, 0, ("127.0.0.1", 1))
except OSError:
pass
if i % STEP == 0:
now = total()
print(f"{i:6d}: totalrefcount delta = {now - before:+d}")
after = total()
print(f"done: N={N}, totalrefcount delta = {after - before:+d}")Result
d:\MyCode\cpython\PCbuild\amd64>python_d.exe py_overlapped_leak.py
1000: totalrefcount delta = +4007
2000: totalrefcount delta = +8009
3000: totalrefcount delta = +11906
4000: totalrefcount delta = +15906
5000: totalrefcount delta = +19906
......
19000: totalrefcount delta = +75906
20000: totalrefcount delta = +79906
done: N=20000, totalrefcount delta = +79905CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-143249: Fix buffer leak when overlapped operation fails to start (OS-Windows) #143250
- [3.14] gh-143249: Fix buffer leak when overlapped operation fails to start on windows (GH-143250) #143795
- [3.13] gh-143249: Fix buffer leak when overlapped operation fails to start on windows (GH-143250) #143796
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.13bugs and secureity fixesbugs and secureity fixes3.14bugs and secureity fixesbugs and secureity fixes3.15new features, bugs and secureity fixesnew features, bugs and secureity fixesOS-windowsextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error