Skip to content

Refcount error and file descriptor leaks in pwd, grp modules #49123

Closed

Description

@baikie
mannequin
BPO 4873
Nosy @loewis
Files
  • minor.diff: Fix refcount error and fd leaks
  • 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 2009-05-29.16:05:21.068>
    created_at = <Date 2009-01-07.22:30:45.644>
    labels = ['extension-modules', 'performance']
    title = 'Refcount error and file descriptor leaks in pwd, grp modules'
    updated_at = <Date 2009-05-29.16:05:21.061>
    user = 'https://bugs.python.org/baikie'

    bugs.python.org fields:

    activity = <Date 2009-05-29.16:05:21.061>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-05-29.16:05:21.068>
    closer = 'loewis'
    components = ['Extension Modules']
    creation = <Date 2009-01-07.22:30:45.644>
    creator = 'baikie'
    dependencies = []
    files = ['12639']
    hgrepos = []
    issue_num = 4873
    keywords = ['patch']
    message_count = 2.0
    messages = ['79378', '88513']
    nosy_count = 2.0
    nosy_names = ['loewis', 'baikie']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue4873'
    versions = []

    Activity

    1. baikie commented on Jan 7, 2009

      baikiemannequin
      MannequinAuthor

      When investigating issue bpo-4859 I found that when pwd.getpwall()
      and grp.getgrall() fail due to decoding errors, they leave open
      file descriptors referring to the passwd and group files, since
      they don't call the end*ent() functions in this case. Also, the
      grp.* functions have a reference counting error when they fail in
      this way - a debug build reports that an object's reference count
      goes to -1. What I think happens is that in mkgrent(),
      PyStructSequence_SET_ITEM steals the reference to "w", meaning
      that the "Py_DECREF(w)" call shouldn't be made afterwards. The
      attached diff fixes both of these problems, I think, and applies
      to the 2.x and 3.x branches.

    2. loewis commented on May 29, 2009

      loewismannequin
      Mannequin

      Thanks for the patch. Committed as r73016, r73017, r73018, r73019.

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      extension-modulesC modules in the Modules dirperformancePerformance or resource usage

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions