#14159: Don't install callbacks on values of TripleDict, MonoDict
---------------------------------+------------------------------------------
       Reporter:  nbruin         |         Owner:  tbd     
           Type:  PLEASE CHANGE  |        Status:  new     
       Priority:  major          |     Milestone:  sage-5.8
      Component:  PLEASE CHANGE  |    Resolution:          
       Keywords:                 |   Work issues:          
Report Upstream:  N/A            |     Reviewers:          
        Authors:                 |     Merged in:          
   Dependencies:                 |      Stopgaps:          
---------------------------------+------------------------------------------

Comment (by nbruin):

 Ouch, I looked at that code and you're correct: That doesn't overwrite the
 value at all (it's really a cache). Incidentally, at that code:
 {{{
     try:
         H = _cache[key]()
     except KeyError:
         H = None
     if H is not None:
         # Are domain or codomain breaking the unique parent condition?
         if H.domain() is X and H.codomain() is Y:
             return H
 }}}
 Since `X,Y` are part of key, which is looked up by identity, the "domain"
 and "codomain" test should really be superfluous. So perhaps we want
 {{{
 if H is not None:
    assert H.domain() is X and H.codomain() is Y
    return H
 }}}
 since something is going very wrong if this is not the case! (H would not
 be allowed to sit there in the dict).

 Furthermore, `H` has strong references to `X,Y,category` in the form of
 `H.domain()`, `H.codomain()` and `H.homset_category()`, so if H is alive
 then so must the keys. Which means that the callback on H must happen (or
 be purged) before those on `X,Y` etc., or at least in the same GC.
 so their `id`s can't get reused until their callbacks have happened or
 have been discarded.

 I think that only leaves the possibility that `_cache` got silently
 corrupted due to a GC at an inopportune time before this particular error.
 We cannot rule that out, but it's extremely unlikely: It requires a bucket
 to be rather full and buckets are typically not full at all (ideally only
 one entry).

 On the other hand, since this is a global _cache, it does get to hold
 quite a few keys, so it's quite likely that it underwent a `resize`
 operation, where a corruption was much more likely to happen.

 It's rather difficult to do an accurate postmortem with so little data.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14159#comment:10>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to