This repository was archived by the owner on Feb 13, 2025. It is now read-only.
forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 61
slp_prepare_slots leaks memory #135
Labels
Milestone
Comments
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
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
Oct 29, 2017
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)
Fixed. |
akruis
pushed a commit
that referenced
this issue
Dec 21, 2017
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.
slp_prepare_slots() called twice
The function
slp_prepare_slots(PyTypeObject * type)
gets called from two places.From
init_stackless_methods()
. Hereinit_stackless_methods()
sets Py_TPFLAGS_HAVE_STACKLESS_EXTENSION before calling slp_prepare_slots(). Everything is fine.From
inherit_slots()
intypeobject.c
by theCOPY*()
macros. These macros do not setPy_TPFLAGS_HAVE_STACKLESS_EXTENSION
. Thereforeslp_prepare_slots()
gets calledtwice.
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 classtype
). If Py_TPFLAGS_HAVE_STACKLESS_EXTENSION and Py_TPFLAGS_HEAPTYPE are set,tp_as_mapping
was allocated by slp_prepare_slots()The text was updated successfully, but these errors were encountered: