镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

slp_prepare_slots leaks memory #135

Closed

Description

@akruis

slp_prepare_slots() called twice

The function slp_prepare_slots(PyTypeObject * type) gets called from two places.

  1. From init_stackless_methods(). Here init_stackless_methods() sets Py_TPFLAGS_HAVE_STACKLESS_EXTENSION before calling slp_prepare_slots(). Everything is fine.

  2. From inherit_slots() in typeobject.c by the COPY*() macros. These macros do not set Py_TPFLAGS_HAVE_STACKLESS_EXTENSION. Therefore slp_prepare_slots() gets called
    twice.

Fix: Set Py_TPFLAGS_HAVE_STACKLESS_EXTENSION only in slp_prepare_slots()

The allocated PyMappingMethods is never freed

No problem for static types, but it is a problem for heap types. We can free the memory in the tp_dealloc slot function of PyType_Type (Python class type). If Py_TPFLAGS_HAVE_STACKLESS_EXTENSION and Py_TPFLAGS_HEAPTYPE are set, tp_as_mapping was allocated by slp_prepare_slots()

Activity

  1. added this to the v3.6.x-slp milestone on Oct 8, 2017
  2. added a commit that references this issue on Oct 10, 2017
  3. added 5 commits that reference this issue on Oct 29, 2017
  4. akruis commented on Nov 5, 2017

    @akruis
    Author

    Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions