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

Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the CLI flag #79901

Closed
Lucas-C mannequin opened this issue Jan 11, 2019 · 4 comments
Closed

Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the CLI flag #79901

Lucas-C mannequin opened this issue Jan 11, 2019 · 4 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes performance Performance or resource usage

Comments

@Lucas-C
Copy link
Mannequin

Lucas-C mannequin commented Jan 11, 2019

BPO 35720
Nosy @vstinner, @miss-islington, @Lucas-C
PRs
  • bpo-35720: Fixing a memory leak in Modules/main.c:pymain_parse_cmdline_impl #11528
  • bpo-35720: Fixing a memory leak in Modules/main.c:pymain_parse_cmdline_impl #11528
  • bpo-35720: Fixing a memory leak in Modules/main.c:pymain_parse_cmdline_impl #11528
  • [3.7] bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528) #11648
  • [3.7] bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528) #11648
  • 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-01-22.16:43:52.001>
    created_at = <Date 2019-01-11.19:14:02.668>
    labels = ['3.7', '3.8', 'performance']
    title = 'Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the CLI flag'
    updated_at = <Date 2019-01-22.16:43:52.000>
    user = 'https://github.com/Lucas-C'

    bugs.python.org fields:

    activity = <Date 2019-01-22.16:43:52.000>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-01-22.16:43:52.001>
    closer = 'vstinner'
    components = []
    creation = <Date 2019-01-11.19:14:02.668>
    creator = 'Lucas Cimon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35720
    keywords = ['patch', 'patch', 'patch']
    message_count = 4.0
    messages = ['333499', '334217', '334220', '334221']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'miss-islington', 'Lucas Cimon']
    pr_nums = ['11528', '11528', '11528', '11648', '11648']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue35720'
    versions = ['Python 3.7', 'Python 3.8']

    @Lucas-C
    Copy link
    Mannequin Author

    Lucas-C mannequin commented Jan 11, 2019

    Hi.

    I think I have found a minor memory leak in Modules/main.c:pymain_parse_cmdline_impl.

    When the loop in the pymain_read_conf function in this same file
    calls pymain_init_cmdline_argv a 2nd time, the pymain->command
    buffer of wchar_t is overriden and the previously allocated memory
    is never freed.

    I haven't written any code test to reproduce this,
    but it can be tested easily with gdb:

    gdb -- bin/python3 -c pass
    start
    b Modules/main.c:587
    b pymain_clear_pymain
    c
    c
    

    You'll see that PyMem_RawMalloc is called twice without pymain->command ever being freed in pymain_clear_pymain.

    I have a patch coming as PR on GitHub

    I'd be glad to have your feedback on this issue and my proposal for a fix.

    Regards.

    @SilentGhost SilentGhost mannequin added 3.7 (EOL) end of life 3.8 only security fixes performance Performance or resource usage labels Jan 14, 2019
    @vstinner
    Copy link
    Member

    New changeset 35ca182 by Victor Stinner (Lucas Cimon) in branch 'master':
    bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528)
    35ca182

    @miss-islington
    Copy link
    Contributor

    New changeset f71e743 by Miss Islington (bot) in branch '3.7':
    bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528)
    f71e743

    @vstinner
    Copy link
    Member

    Thanks Lucas Cimon!

    @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.7 (EOL) end of life 3.8 only security fixes performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants