#14471: Exception KeyError: in WeakValueDictionary remove ignored
---------------------------+------------------------------------------------
Reporter: vbraun | Owner: rlm
Type: defect | Status: new
Priority: major | Milestone: sage-5.10
Component: memleak | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
---------------------------+------------------------------------------------
Comment (by nbruin):
Replying to [comment:5 vbraun]:
> So the weakvaluedict (self.data) is in a bad state...
`self.data` is a normal dict. Your example doesn't quite show the dict is
in a "bad state". It shows that between testing whether the key is in the
dict and doing the delete, the key has been removed. That's not quite the
same as `self.data` beng corrupted.
Something is going wrong of course, though. Something seems to be mutating
self.data in between. The only methods that seem to be mutating the
underlying `self.data` for a `WeakValueDictionary` are `__setitem__`,
`popitem`, `pop`, `setdefault`, `update` (and of course `__delitem__` and
`clear` it inherits from `UserDict`). Perhaps I don't have enough
imagination, but indeed the only scenario in which I could see one of
those happening during a callback is when a GC gets triggered and
basically the whole dict gets cleaned up.
Some of the "iterator" methods on `WeakValueDict` don't quite seem safe to
me, by the way. The `iteritems` method, for instance, iterates over
`self.data.itervalues()`, but `self.data` can be mutated outside of your
control due to GC callbacks, and iterators over a mutating dict are
generally not safe.
I doubt that's what's hurting us here, though.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14471#comment:6>
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.