#12408: Segfault in Sage 4.8 with matrices, generator expressions, and Cython
------------------------------+---------------------------------------------
Reporter: nthiery | Owner: jason, was
Type: defect | Status: new
Priority: major | Milestone: sage-5.0
Component: linear algebra | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
------------------------------+---------------------------------------------
Description changed by nthiery:
Old description:
> The following piece of code, inserted in the matrix code, triggers a
> segfault in Sage 4.8, whereas it used to work in 4.7.2:
>
> {{{
> def _travel_column( self, dict d, int k):
> r"""
> Triggers a seg fault in Sage 4.8 but not 4.7.2
>
> sage: M = matrix(ZZ,3,[0,1,0,-1,0,-1,0,1,0]); M
> [ 0 1 0]
> [-1 0 -1]
> [ 0 1 0]
> sage: M._travel_column({0:1},0)
> ** BOOM, Segfault **
>
> """
> cdef int i
> for i from 0 <= i < self.ncols():
> d[i] = 1
> print any(self[i,j] != 1 for j in d)
> }}}
>
> To reproduce: apply the attached patch on vanilla Sage 4.8, and run
> the example above. Platform: at least Ubuntu 11.10 on a Macbook pro.
>
> Note: the code is meaningless by itself; it's the smallest reduction I
> could make of a real piece of code that triggered the seg fault in the
> first place (#10347). For example there is no segfault if `any` is
> replaced by a list comprehension. I suspect this issue to be related
> to the upgraded iterators in the new version of Cython included in
> Sage.
>
> Cython experts, please!
>
> Also, please update the component once we know more precisely what the
> issue is.
New description:
The following piece of code, inserted in the matrix code, triggers a
segfault in Sage 4.8, whereas it used to work in 4.7.2:
{{{
def _travel_column( self, dict d, int k):
r"""
Triggers a seg fault in Sage 4.8 but not 4.7.2
sage: M = matrix(ZZ,3,[0,1,0,-1,0,-1,0,1,0]); M
[ 0 1 0]
[-1 0 -1]
[ 0 1 0]
sage: M._travel_column({0:1},0)
** BOOM, Segfault **
"""
cdef int i
for i from 0 <= i < self.ncols():
d[i] = 1
print any(self[i,j] != 1 for j in d)
}}}
To reproduce: apply the attached patch on vanilla Sage 4.8, and run
the example above. Platform: at least Ubuntu 11.10 on a Macbook pro.
I suspect this issue to be related to the upgraded iterators in the
new version of Cython included in Sage.
Note: the code is meaningless by itself; it's the smallest reduction I
could make of a real piece of code that triggered the seg fault in the
first place (#10347). For example there is no segfault if `any` is
replaced by a list comprehension. Also, without the for loop, I get
an exception ``NameError: free variable 'self' referenced before
assignment in enclosing scope''.
Cython experts, please!
Please someone update the component of this ticket once we know more
precisely what the issue is.
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12408#comment:1>
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.