On Wednesday, December 26, 2012 8:22:24 PM UTC+1, Jean-Pierre Flori wrote: > > > > On Wednesday, December 26, 2012 8:20:03 PM UTC+1, Jean-Pierre Flori wrote: >> >> >> >> On Wednesday, December 26, 2012 8:08:24 PM UTC+1, Jean-Pierre Flori wrote: >>> >>> >>> >>> On Wednesday, December 26, 2012 6:49:52 PM UTC+1, Jean-Pierre Flori >>> wrote: >>>> >>>> The offending object seems to be a weakref which is not refcounted >>>> correctly. >>>> Not sure which yet. >>>> >>> Not sure why, but it might be the one initialized by the Expect class at >>> the line: >>> quit.expect_objects.append(weakref.ref(self)) >>> >>> If I add: >>> import gc >>> print gc.get_referrers(quit.expect_objects[-1]) >>> >>> I get: >>> [Mathematica, [<weakref at 0x21c07c0; to 'Mathematica' at 0x21bd490>]] >>> >>> Strange that Mathematica points to its weakref. >>> The second member is quit.expect_object I assume. >>> >> Really strange. >> If I del the weakref and then mathematica (from >> sage.interfaces.mathematica), everything is fine (until it fails later in >> InfinityRing). >> But if I try to del mathematica directly, then bang! >> > (Using sys.getrefcount shows there is no problem until the call to del) >
In fact it may be a Cython misuse (or bug?). The following minimal example seems to reproduce the issue: In some .pxd file: cdef class CFake: cdef object __weakref__ In some .py file: import gc, weakref, quit from sage.structure.cfake import CFake class Fake(CFake): def __init__(self): L.append(weakref.ref(self)) a=Fake() import gc print gc.get_referrers(quit.expect_objects[-1]) import sys print sys.getrefcount(quit.expect_objects[-1]) gc.collect() -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To post to this group, send email to sage-devel@googlegroups.com. To unsubscribe from this group, send email to sage-devel+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en.