Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_asyncio: SubprocessPidfdWatcherTests..test_close_dont_kill_finished() leaks a file descriptor #83163

Closed
vstinner opened this issue Dec 5, 2019 · 5 comments
Labels
3.9 only security fixes tests Tests in the Lib/test dir topic-asyncio

Comments

@vstinner
Copy link
Member

vstinner commented Dec 5, 2019

BPO 38982
Nosy @vstinner, @asvetlov, @1st1, @pablogsal
PRs
  • bpo-38982: Fix asyncio PidfdChildWatcher on waitpid() error #17477
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-12-06.17:36:33.807>
    created_at = <Date 2019-12-05.17:09:01.917>
    labels = ['tests', '3.9', 'expert-asyncio']
    title = 'test_asyncio: SubprocessPidfdWatcherTests..test_close_dont_kill_finished() leaks a file descriptor'
    updated_at = <Date 2019-12-06.17:36:33.803>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-12-06.17:36:33.803>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-12-06.17:36:33.807>
    closer = 'vstinner'
    components = ['Tests', 'asyncio']
    creation = <Date 2019-12-05.17:09:01.917>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38982
    keywords = ['patch']
    message_count = 5.0
    messages = ['357869', '357871', '357873', '357919', '357928']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'asvetlov', 'yselivanov', 'pablogsal']
    pr_nums = ['17477']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue38982'
    versions = ['Python 3.9']

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 5, 2019

    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

    @vstinner vstinner added 3.9 only security fixes tests Tests in the Lib/test dir topic-asyncio labels Dec 5, 2019
    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 5, 2019

    Attached PR 17477 fix the leak.

    PidfdChildWatcher was added to asyncio by bpo-38692:

    commit 3ccdd9b
    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)
    

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 5, 2019

    The test only fails on the Fedora Rawhide buildbot, likely because other Linux Refleak buildbots are using a kernel or libc without pidfd_open() ;-)

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 6, 2019

    New changeset e76ee1a by Victor Stinner in branch 'master':
    bpo-38982: Fix asyncio PidfdChildWatcher on waitpid() error (GH-17477)
    e76ee1a

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 6, 2019

    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 ;-)

    @vstinner vstinner closed this as completed Dec 6, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes tests Tests in the Lib/test dir topic-asyncio
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant