Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
Closed
Description
Bug report
Bug description:
On Windows, some overlapped I/O operations leak buffers when they fail to start, includingWSASendTo(),WSARecvFrom(), andWSARecvFromInto().
Python script for tracking leaks
importsysimport_overlappeddeftotal():returnsys.gettotalrefcount()ifnothasattr(sys,"gettotalrefcount"):raiseSystemExit("need a debug build (Py_DEBUG) for gettotalrefcount")before=total()N=20000STEP=1000foriinrange(1,N+1):ov=_overlapped.Overlapped()buf=memoryview(bytearray(4096))try:ov.WSASendTo(0x1234,buf,0, ("127.0.0.1",1))exceptOSError:passifi%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 = +79906done: N=20000, totalrefcount delta = +79905
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows