On Wed, Feb 03, 2010 at 04:28:00AM +1100, Minh Nguyen wrote:
> Hi folks,
> >        sage -t  "devel/sage/sage/structure/element_wrapper.py" # Segfault
> 
> I get the same result on bsd.math (Mac OS X 10.6.2). Doing a verbose
> long doctest, I get:
> 
> Trying:
>     Integer(1) < l11###line 213:_sage_    >>> 1 < l11
> Expecting:
>     False

Ouch. Well, ElementWrapper is a pure python class, and here the crash
is probably in the comparison function for Integer's. Ah, but 1 and
l11 have the same parent (that's just because, for the tests, I needed
a parent to use). Maybe the comparison function of Integer then gets
confused by this, and wrongly assumes that l11 is an Integer and does
some wrong memory manipulation. If that's the case, then the following
should be a fairly minimal code causing the crash:

    sage: class F(Element):
    ....:     pass
    ....: 
    sage: x = F(ZZ)
    sage: 1 < x
    False

If this is confirmed, I don't mind using a more sane parent for the
tests. On the other hand, getting a segfault with an (admittedly ill)
piece of pure Python code is not good. Could any expert of the arcanes
of Integer comparison have a look?

Cheers,
                                        Nicolas


> ----------------------------------------------------------------------
> The following tests failed:
> 
> 
>       sage -t -verbose -long 
> "devel/sage-main/sage/structure/element_wrapper.py"
> 
> The relevant doctest from sage/structure/element_wrapper.py that
> causes the segfault is:
> 
> sage: class MyElement(ElementWrapper):
> ...       __lt__ = ElementWrapper._lt_by_value
> ...
> sage: parent1 = ZZ
> sage: parent2 = QQ
> sage: l11 = MyElement(1, parent = parent1)
> sage: l12 = MyElement(2, parent = parent1)
> sage: l21 = MyElement(1, parent = parent2)
> sage: l22 = MyElement(2, parent = parent2)
> sage: l11 < l11
> False
> sage: l11 < l12, l12 < l11   # values differ
> (True, False)
> sage: l11 < l21              # parents differ
> False
> sage: l11 < 1                # class differ
> False
> sage: 1 < l11
> False
> 
> -- 
> Regards
> Minh Van Nguyen
> 
> -- 
> To post to this group, send an email to sage-devel@googlegroups.com
> To unsubscribe from this group, send an email to 
> sage-devel+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to