#13901: Fix cython's deep C-stacks upon deallocation
-------------------------------------------------------+--------------------
Reporter: nbruin | Owner: rlm
Type: defect | Status: new
Priority: major | Milestone:
sage-5.6
Component: memleak | Resolution:
Keywords: | Work issues:
Report Upstream: Reported upstream. No feedback yet. | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
-------------------------------------------------------+--------------------
Comment (by nbruin):
Replying to [comment:3 jpflori]:
> But shouldn't we just ignore such extensions? i.e. if we detect we are
in the Cython world and giving hand to another Cython deallocator, we
should not trick the trashcan magic by reincrementing
_Py_Trash_delete_nesting until we hit a non Cython type.
The problem there is that if the type gets trashcanned halfway up the
tower, the pointer would be added to the trashcan we'd be returning all
the way up to the leaf class dealloc instance. That would decref and free
the memory block. Once the trashcan gets emptied, the pointer (now
masquerading as an instance of one of the supers) gets processed again and
again decreffed and freed. That's the double-free we're trying to avoid.
For cython, the appropriate solution is probably something along the lines
of
{{{
Py_TRASHCAN_SAFE_BEGIN(self);
...
Clear_Weakrefs()
PY_CLEAR(slots)
...
--_PyTrash_delete_nesting;
super.dealloc(self)
++_PyTrash_delete_nesting;
...
Py_TRASHCAN_SAFE_END(self);
}}}
i.e., `PY_CLEAR` etc. can lead to trashcanning, but not the calling of the
`dealloc` of the super class. The python code figured that left a loophole
open, but I think in cython that's not a loophole but a necessity: If you
nest your inheritance deeper than the C-stack, you're asking for it.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13901#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.