#13896: Fix cython's gc_track and gc_untrack
------------------------------------------------------------------+---------
       Reporter:  nbruin                                          |         
Owner:  rlm     
           Type:  defect                                          |        
Status:  new     
       Priority:  blocker                                         |     
Milestone:  sage-5.6
      Component:  memleak                                         |    
Resolution:          
       Keywords:                                                  |   Work 
issues:          
Report Upstream:  Reported upstream. Developers acknowledge bug.  |     
Reviewers:          
        Authors:                                                  |     Merged 
in:          
   Dependencies:                                                  |      
Stopgaps:          
------------------------------------------------------------------+---------

Comment (by robertwb):

 I think it helps to look at the generated code. Suppose one has

 {{{
 cdef class A: ...
 cdef class B(A): ...
 cdef class C(B): ...
 ...
 }}}

 In this case one has, roughly,

 {{{
 tp_dealloc_A(self) {
    [optional untrack]
    bodyA
    [optional track]
    PY_TYPE(self)->tp_free(self)
 }

 tp_dealloc_B(self) {
    [optional untrack]
    bodyB
    [optional track]
    tp_dealloc_A(self)
 }

 tp_dealloc_C(self) {
    [optional untrack]
    bodyC
    [optional track]
    tp_dealloc_B(self)
 }

 ...

 }}}

 bodyX consists of decrefing Python members, traversing weakrefs, and (if
 present)

 {{{
 PyRef(self)++;
 X.__dealloc__(self);
 PyRef(self)--;
 }}}

 The track/untrack markers are added exactly when Python/weakref members
 are present, which is where a garbage collection might happen.  (When
 executing __dealloc__ the refcount is incremented, also preventing garbage
 collection.)

 What could be an issue is a non-gc-tracked container class that is
 subclassed by a gc-tracked class, but we don't have those in Cython.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13896#comment:20>
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.

Reply via email to