#12313: Fix yet another memory leak caused by caching of coercion data
--------------------------------------------------+-------------------------
       Reporter:  SimonKing                       |         Owner:              
                             
           Type:  defect                          |        Status:  
needs_review                             
       Priority:  major                           |     Milestone:  sage-5.3    
                             
      Component:  memleak                         |    Resolution:              
                             
       Keywords:  coercion weak dictionary        |   Work issues:              
                             
Report Upstream:  N/A                             |     Reviewers:  Simon King, 
Jean-Pierre Flori, John Perry
        Authors:  Simon King, Jean-Pierre Flori   |     Merged in:              
                             
   Dependencies:  #11521, #11599, #12969, #12215  |      Stopgaps:              
                             
--------------------------------------------------+-------------------------

Comment (by SimonKing):

 Now that's funny. I tried to keep the store of any `KeyedReference`. But
 it turns out that there is always ''exactly one'' dead `KeyedReference`
 that raises an attribute error when trying to get the key. Namely, I
 inserted the following at the beginning of sage.all.quit_sage:
 {{{
 #!python
     import gc, weakref
     KeepRefKeys = []
     for r in gc.get_objects():
         if isinstance(r, weakref.KeyedRef):
             try:
                 KeepRefKeys.append(r.key)
             except AttributeError:
                 print "Warning, no key for",r
     del r
     print "all keys are in store"
     gc.collect()
     print "collection done"
 }}}

 Then, quitting a normal Sage session, I get
 {{{
 sage: quit
 Exiting Sage (CPU time 0m0.05s, Wall time 0m0.85s).
 Warning, no key for <weakref at 0x3d281d0; dead>
 all keys are in store
 collection done
 }}}
 and executing the "bad" three-line doctest, I get
 {{{
 6 tests in 5 items.
 6 passed and 0 failed.
 Test passed.
 Warning, no key for <weakref at 0x3a8f290; dead>
 all keys are in store
 *** glibc detected *** python: double free or corruption (out):
 0x0000000004be6cf0 ***
 ^CKeyboardInterrupt -- interrupted after 5.4 seconds!
 Aborting further tests.
 }}}

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