Changes between Initial Version and Version 17 of Ticket #14159


Ignore:
Timestamp:
02/25/13 12:01:39 (7 years ago)
Author:
SimonKing
Comment:

I did not run the full tests yet, but I think the new patch can be reviewed.

I introduce a variant of TripleDictEraser dedicated for use on the values of a TripleDict (if we use a callback for the values of MonoDict then we need to do the same). It will only erase an item if the value is the originally stored weak reference.

The patch contains tests demonstrating that TripleDictEraser is unsafe but TripleDictEraserOnValue is safe on values, and it contains a test demonstrating that homsets can still be garbage collected.

Apply trac_14159_safer_callback.patch

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14159

    • Property Status changed from new to needs_review
    • Property Authors changed from to Simon King
    • Property Component changed from PLEASE CHANGE to memleak
    • Property Reviewers changed from to Nils Bruin
    • Property Type changed from PLEASE CHANGE to defect
  • Ticket #14159 – Description

    initial v17  
    77So: Either prove that the value under this key will not change for the lifetime of H (keep in mind that cyclic references can extend the lifetime of an otherwise unreachable object essentially indefinitely, so the proof needs to include that all key components survive H, otherwise those ids could get reused) or provide a more selective callback (for instance, ensure that the value is still as expected before deleting).
    88
     9'''Note:''' The patch trac_14159_safer_callback.patch follows the second approach, so that a memory leak remains fixed.
     10
    911Another point is that the API of `_cache.eraser` isn't really published, so this behaviour is probably better encapsulated in a method on the dict itself.
    1012
    1113See [http://trac.sagemath.org/sage_trac/ticket/12313#comment:317 #12313 comment 317] for a situation that likely implicates these callbacks (someone has to hold strong references to these keys in order to set the dict, so the absence of the keys suggests a spurious execution of this kind of callback)
     14
     15__Apply__
     16
     17- [attachment:trac_14159_safer_callback.patch]