Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Overlapped I/O leaks buffers when operation fails to start #143249

Closed
Labels
3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesOS-windowsextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error
@hyongtao-code

Description

@hyongtao-code

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesOS-windowsextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp