sage: from sage.rings.complex_number import ComplexNumber as CN
sage: parent(1+I)
Symbolic Ring
sage: coerce(CN, 1+I)
BOOM
(with 4.8.alpha1 and 4.7.2 in 64-bit Linux)
It looks like mpfr is extremely unhappy about something.
Also, if I just use the regular ComplexNumber in the global namespace
with the same command, I get "TypeError: unable to coerce to a
ComplexNumber: <type 'str'>". I understand that coercion may not be able
to handle SymbolicRing stuff to complex, but that's a strange message,
especially since ComplexNumber claims that it wants strings to convert.
But for now let's just deal with the segfault.
Dan
--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------
It looks like something bad happens also on 4.7. At least, when I try
on demo.sagenb.org (running 4.7 currently), after I do the coerce
statement above, it appears that the worksheet is abruptly reset and CN
is no longer defined.
Jason
I also get a segfault in: 4.6, 4.5.1, 4.4, and 4.3. That's as far back
as I have copies of Sage.
On Mon, 14 Nov 2011 at 08:11PM -0600, Jason Grout wrote:
> It looks like something bad happens also on 4.7. At least, when I
> try on demo.sagenb.org (running 4.7 currently), after I do the
> coerce statement above, it appears that the worksheet is abruptly
> reset and CN is no longer defined.I also get a segfault in: 4.6, 4.5.1, 4.4, and 4.3. That's as far back
as I have copies of Sage.
I get segfaults for both cases ('CN' and 'ComplexNumber') all the way back to 2.11 (I've tried most of the 4.x releases, some of the 3.x's and only one of the 2's). I don't see the "TypeError" failure in any case.
Justin
--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
--
Democracy is two wolves and a lamb
voting on what to have for lunch.
Liberty is a well-armed lamb contesting
the vote.
The problem was that you shouldn't be using coerce like that: the
first argument should be a parent, not the element class. That
element class requires two inputs: both the parent and the data to
make a new element out of. In this case, the __init__ method was only
getting one input (1+I) and thus raising a TypeError. There's now no
reference to your new ComplexNumber, so it's deallocated, but the
mpfrs are only initialized in the __init__ method, which was never
called. So when you try to clear them in __dealloc__, you get a
segfault.
David
> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>