Skip to content

Refleaks in pythonrun.c #54366

Closed
Closed

Description

@skrah
mannequin
BPO 10157
Nosy @amauryfa, @pitrou, @vstinner, @benjaminp, @skrah
Files
  • py3k_issue10157.patch
  • pythonrun3.patch
  • 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 2010-10-30.15:46:46.675>
    created_at = <Date 2010-10-20.17:33:20.107>
    labels = ['interpreter-core', 'type-bug']
    title = 'Refleaks in pythonrun.c'
    updated_at = <Date 2010-10-30.15:46:46.673>
    user = 'https://github.com/skrah'

    bugs.python.org fields:

    activity = <Date 2010-10-30.15:46:46.673>
    actor = 'ocean-city'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-10-30.15:46:46.675>
    closer = 'ocean-city'
    components = ['Interpreter Core']
    creation = <Date 2010-10-20.17:33:20.107>
    creator = 'skrah'
    dependencies = []
    files = ['19321', '19341']
    hgrepos = []
    issue_num = 10157
    keywords = ['patch']
    message_count = 9.0
    messages = ['119227', '119234', '119269', '119273', '119305', '119333', '119435', '119547', '119997']
    nosy_count = 6.0
    nosy_names = ['amaury.forgeotdarc', 'pitrou', 'vstinner', 'ocean-city', 'benjamin.peterson', 'skrah']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue10157'
    versions = ['Python 3.1', 'Python 3.2']

    Activity

    1. skrah commented on Oct 20, 2010

      skrahmannequin
      MannequinAuthor

      This is one of two remaining "definitely lost" leaks in py3k. It first
      appeared in r70152. How to reproduce:

      make distclean && ./configure OPT="-O0 -g" --without-pymalloc && make

      valgrind --leak-check=full --suppressions=Misc/valgrind-python.supp ./python > VGOUT 2>&1

      Then search for 'definitely'. This leak is not present in release-2.7.

      ==25233== 106 (56 direct, 50 indirect) bytes in 1 blocks are definitely lost in loss record 1,432 of 2,121
      ==25233== at 0x4C2412C: malloc (vg_replace_malloc.c:195)
      ==25233== by 0x4167AE: _PyObject_New (object.c:243)
      ==25233== by 0x42C1C4: _PyUnicode_New (unicodeobject.c:341)
      ==25233== by 0x430562: PyUnicodeUCS2_DecodeUTF8Stateful (unicodeobject.c:2036)
      ==25233== by 0x430516: PyUnicodeUCS2_DecodeUTF8 (unicodeobject.c:2001)
      ==25233== by 0x479F81: r_object (marshal.c:726)
      ==25233== by 0x47A03E: r_object (marshal.c:745)
      ==25233== by 0x47A720: r_object (marshal.c:873)
      ==25233== by 0x47AF4B: PyMarshal_ReadObjectFromString (marshal.c:1053)
      ==25233== by 0x47AE2A: PyMarshal_ReadLastObjectFromFile (marshal.c:1012)
      ==25233== by 0x471C5B: read_compiled_module (import.c:823)
      ==25233== by 0x47230C: load_source_module (import.c:1043)

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on Oct 20, 2010
    3. skrah commented on Oct 20, 2010

      skrahmannequin
      MannequinAuthor

      I tracked it down to r68683, which is still a large commit.

    4. pitrou commented on Oct 21, 2010

      @pitrou
      Member

      Your traceback suggests it's a string allocated when reading a module file...

    5. skrah commented on Oct 21, 2010

      skrahmannequin
      MannequinAuthor

      I also thought that it might be a pointer that's lost in marshal.c.
      However, perhaps a pointer is lost in Py_Finalize. With this ...

      Index: Modules/main.c
      ===================================================================

      --- Modules/main.c      (revision 85766)
      +++ Modules/main.c      (working copy)
      @@ -697,6 +697,7 @@
               sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
           }
       
      +    exit(0);
           Py_Finalize();
       
       #ifdef __INSURE__

      ... Valgrind does not report the leak.

    6. ocean-city commented on Oct 21, 2010

      ocean-citymannequin
      Mannequin

      Hello. Does this patch fix the problem?

    7. skrah commented on Oct 21, 2010

      skrahmannequin
      MannequinAuthor

      Hirokazu, the patch looks good to me. Unfortunately Valgrind still
      reports the leak.

    8. skrah commented on Oct 23, 2010

      skrahmannequin
      MannequinAuthor

      After taking the scenic route through half of the tree[1], I finally
      found another leak in pythonrun.c. I'm closing bpo-10153, merging those
      two leaks into the new patch.

      Does it look ok?

      [1] Valgrind stack traces should be approached with caution.

    9. changed the title [-]Memory leak (r70152)[/-] [+]Refleaks in pythonrun.c[/+] on Oct 23, 2010
    10. ocean-city commented on Oct 25, 2010

      ocean-citymannequin
      Mannequin

      I think your patch looks good.

    11. self-assigned this
      on Oct 25, 2010
    12. ocean-city commented on Oct 30, 2010

      ocean-citymannequin
      Mannequin

      Thank you, I committed your patch in r85980(py3k) and
      r85981(release31-maint).

    13. removed their assignment
      on Oct 30, 2010
    14. 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

      interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions