Skip to content

gh-154137: Check for Windows handle leaks in regrtest#154140

Draft
vstinner wants to merge 4 commits into
python:mainfrom
vstinner:handle_count
Draft

gh-154137: Check for Windows handle leaks in regrtest#154140
vstinner wants to merge 4 commits into
python:mainfrom
vstinner:handle_count

Conversation

@vstinner

@vstinner vstinner commented Jul 19, 2026

Copy link
Copy Markdown
Member

Add handle_count() to test.support.os_helper.

Add handle_count() to test.support.os_helper.
@vstinner

Copy link
Copy Markdown
Member Author

I found a leak when running tests on Windows using python -m test -R 3:3 -j0 -r:

test.test_concurrent_futures.test_process_pool leaked [24, 24, 24] handles, sum=72

I can reproduce at least one of these leaks by running test_force_shutdown_workers():

C:> python -m test test_concurrent_futures.test_process_pool -R 3:3 -m test_force_shutdown_workers   
...
test_concurrent_futures.test_process_pool leaked [4, 4, 4] handles, sum=12
...

@vstinner

Copy link
Copy Markdown
Member Author

test_socket leaks 1 handle:

vstinner@WIN C:\victor\python\main>python -m test -R 3:3 test_socket     
...
test_socket leaked [1, 1, 1] handles, sum=3
...

@vstinner

Copy link
Copy Markdown
Member Author

TODO: Update test_getfinalpathname_handles() of Lib/test/test_os/test_windows.py to reuse support.handle_count().

@vstinner

Copy link
Copy Markdown
Member Author

test_socket leaks 1 handle

I cannot identify the leaking test by running python -m test.bisect_cmd, so I'm not sure that it's a real leak.

@vstinner

Copy link
Copy Markdown
Member Author

!buildbot AMD64 Windows11 Refleaks PR

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 37c29f3 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F154140%2Fmerge

The command will test the builders whose names match following regular expression: AMD64 Windows11 Refleaks PR

The builders matched are:

  • AMD64 Windows11 Refleaks PR

@vstinner

Copy link
Copy Markdown
Member Author

Ah, test_pathlib fails on Windows. I will fix later.

First, I'm waiting for Windows11 Refleaks buildbot report.

@vstinner

Copy link
Copy Markdown
Member Author

Oh, it seems like test_multiprocessing_spawn.test_processes also leaks:

test.test_multiprocessing_spawn.test_processes leaked [36, 36, 36] handles, sum=108

@vstinner

Copy link
Copy Markdown
Member Author

Aaaand last but not least:

test_winapi leaked [8482, 8482, 8482] handles, sum=25446

vstinner added 2 commits July 19, 2026 23:42
Reuse os_helper.handle_count() in test_os.test_windows.
@vstinner

Copy link
Copy Markdown
Member Author

!buildbot AMD64 Windows11 Refleaks PR

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit e66fb14 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F154140%2Fmerge

The command will test the builders whose names match following regular expression: AMD64 Windows11 Refleaks PR

The builders matched are:

  • AMD64 Windows11 Refleaks PR

@vstinner

Copy link
Copy Markdown
Member Author

TODO: Update test_getfinalpathname_handles() of Lib/test/test_os/test_windows.py to reuse support.handle_count().

Done.

test_winapi leaked [8482, 8482, 8482] handles, sum=25446

Fixed by PR gh-154201.

test.test_multiprocessing_spawn.test_processes leaked [36, 36, 36] handles, sum=108

I created issue gh-154208 to investigate this leak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants