Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

slp_prepare_slots leaks memory #135

Closed
akruis opened this issue Oct 8, 2017 · 1 comment
Closed

slp_prepare_slots leaks memory #135

akruis opened this issue Oct 8, 2017 · 1 comment

Comments

@akruis
Copy link

akruis commented Oct 8, 2017

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

@akruis akruis added this to the v3.6.x-slp milestone Oct 8, 2017
akruis pushed a commit to akruis/cpython that referenced this issue Oct 10, 2017
This commit reveals a reference leak. See issue python#135,
stackless-dev#135
@akruis akruis mentioned this issue Oct 16, 2017
7 tasks
akruis pushed a commit that referenced this issue Oct 29, 2017
Fix several problems related with slp_prepare_slots():
- set Py_TPFLAGS_HAVE_STACKLESS_EXTENSION in slp_prepare_slots().
- for heap types free the allocated buffer in tp_dealloc
- Allocate the memory from the object domain, because the blocks are
  small (about 74 bytes).
akruis pushed a commit that referenced this issue Nov 5, 2017
Fix several problems related with slp_prepare_slots():
- set Py_TPFLAGS_HAVE_STACKLESS_EXTENSION in slp_prepare_slots().
- for heap types free the allocated buffer in tp_dealloc
- Allocate the memory from the object domain, because the blocks are
  small (about 74 bytes).

(cherry picked from commit e217840)
akruis pushed a commit that referenced this issue Nov 5, 2017
Fix several problems related with slp_prepare_slots():
- set Py_TPFLAGS_HAVE_STACKLESS_EXTENSION in slp_prepare_slots().
- for heap types free the allocated buffer in tp_dealloc
- Allocate the memory from the object domain, because the blocks are
  small (about 74 bytes).

(cherry picked from commit e217840)
akruis pushed a commit that referenced this issue Nov 5, 2017
@akruis
Copy link
Author

akruis commented Nov 5, 2017

Fixed.

@akruis akruis closed this as completed Nov 5, 2017
akruis pushed a commit that referenced this issue Dec 21, 2017
…n#1543)

* bpo-28787: Fix out of tree --with-dtrace builds

* Unsilence directory creation

* Add Misc/NEWS and Misc/ACKS entries.
(cherry picked from commit f6eae5b)
akruis pushed a commit that referenced this issue Mar 4, 2018
* bpo-28787: Fix out of tree --with-dtrace builds

* Unsilence directory creation

* Add Misc/NEWS and Misc/ACKS entries
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant