This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_asyncio: SubprocessPidfdWatcherTests..test_close_dont_kill_finished() leaks a file descriptor
Type: Stage: resolved
Components: asyncio, Tests Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, pablogsal, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2019-12-05 17:09 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17477 merged vstinner, 2019-12-05 17:24
Messages (5)
msg357869 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-05 17:09
See on AMD64 Fedora Rawhide Refleaks 3.x:
https://buildbot.python.org/all/#/builders/82/builds/7

I found the leaking test using test.bisect_cmd:

$ ./python -m test test_asyncio -R 3:3 --fail-env-changed -v -m test.test_asyncio.test_subprocess.SubprocessPidfdWatcherTests.test_close_dont_kill_finished
...
test_asyncio leaked [1, 1, 1] file descriptors, sum=3
msg357871 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-05 17:25
Attached PR 17477 fix the leak.

PidfdChildWatcher was added to asyncio by bpo-38692:

commit 3ccdd9b180f9a3f29c8ddc8ad1b331fe8df26519
Author: Benjamin Peterson <benjamin@python.org>
Date:   Wed Nov 13 19:08:50 2019 -0800

    closes bpo-38692: Add a pidfd child process watcher to asyncio. (GH-17069)
msg357873 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-05 17:29
The test only fails on the Fedora Rawhide buildbot, likely because other Linux Refleak buildbots are using a kernel or libc without pidfd_open() ;-)
msg357919 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-06 15:32
New changeset e76ee1a72b9e3f5da287663ea3daec4bb3f67612 by Victor Stinner in branch 'master':
bpo-38982: Fix asyncio PidfdChildWatcher on waitpid() error (GH-17477)
https://github.com/python/cpython/commit/e76ee1a72b9e3f5da287663ea3daec4bb3f67612
msg357928 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-06 17:36
I manually validated that my change fixed the test_asyncio leak:

$ ./python -m test test_asyncio -R 3:3 --fail-env-changed -v -m test_subprocess
(...)
Tests result: SUCCESS

I close the issue. Thanks Pablo for the review ;-)
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83163
2019-12-06 17:36:33vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg357928

stage: patch review -> resolved
2019-12-06 15:32:46vstinnersetmessages: + msg357919
2019-12-05 17:29:17vstinnersetmessages: + msg357873
2019-12-05 17:25:08vstinnersetmessages: + msg357871
2019-12-05 17:24:02vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request16958
2019-12-05 17:09:01vstinnercreate