#12313: Fix yet another memory leak caused by caching of coercion data
-----------------------------------------------------------------------------------------------------------+
Reporter: SimonKing
| Owner: rlm
Type: defect
| Status: needs_work
Priority: major
| Milestone: sage-5.0
Component: memleak
| Keywords: coercion weak dictionary
Work_issues: Find out why some attribute of a parent is deleted before the
parent's elements are deleted | Upstream: N/A
Reviewer:
| Author: Simon King
Merged:
| Dependencies: #715
-----------------------------------------------------------------------------------------------------------+
Changes (by SimonKing):
* status: needs_review => needs_work
* work_issues: => Find out why some attribute of a parent is deleted
before the parent's elements are
deleted
Comment:
I am not totally sure whether the following problem is caused by this
patch or by #715 or #11521. Anyway, with all three patches applied, I
obtain:
{{{
sage: K.<z> = GF(4)
sage: P.<x> = K[]
sage: del P
sage: del x
sage: import gc
sage: gc.collect()
Exception AttributeError: 'PolynomialRing_field_with_category' object has
no attribute '_modulus' in ignored
148
}}}
As you can observe, some attribute error is ignored, but worse: Cython is
unable to tell ''where'' it is ignored.
The [http://groups.google.com/group/cython-users cython-users] helped me
to track the problem down, using gdb.
The attribute error occurs in the following cdef method defined in
sage/rings/polynomial/polynomial_zz_pex.pyx:
{{{
cdef cparent get_cparent(parent) except? NULL:
if parent is None:
return NULL
cdef ntl_ZZ_pEContext_class c
c = parent._modulus
return &(c.x)
}}}
By the way it is defined, the error is propagated. However, get_cparent is
in fact called in a deallocation method, namely in
sage/rings/polynomial/polynomial_template.pxi:
{{{
def __dealloc__(self):
"""
EXAMPLE::
sage: P.<x> = GF(2)[]
sage: del x
"""
celement_destruct(&self.x,
get_cparent((<Polynomial_template>self)._parent))
}}}
That is interesting for two reasons: (1) Cython can not tell the location
of the error, which I think is a bug in Cython. (2) The attribute _modulus
of `self._parent` is destroyed before self is destroyed.
I find the latter rather strange. As long as self is alive, `self._parent`
can not be deallocated, but when `self._parent` can not be deallocated,
why is `self._parent._modulus` deleted??
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12313#comment:13>
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.