#12266: 3^3^3^3 segfaults
-------------------------+--------------------------------------------------
Reporter: vbraun | Owner: jason, jkantor
Type: defect | Status: new
Priority: major | Milestone: sage-5.0
Component: numerical | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
-------------------------+--------------------------------------------------
Comment(by was):
It is incorrect to say that this "segfaults". In fact, the relevant code
is this from integer.pyx:
{{{
sig_on()
mpz_pow_ui(x.value, (<Integer>self).value, nn if nn > 0 else -nn)
sig_off()
}}}
What happens is that MPIR can't allocate memory for the answer, this
causes a signal, and Sage properly catches the signal. The Sage process
does not crash the first time around. But things get left in a screwed
up state, so that subsequence calls can totally crash Sage.
On 64-bit OS X I have to use this input to cause the problem:
{{{
a = 2^(2^60)
}}}
It would be nice if a MemoryError is raised instead of a RuntimeError, of
course. I don't know how to put MPIR back in a clean state after this
error occurs though. This on OS X:
{{{
sage: a = 2^(2^60)
python(64816) malloc: *** mmap(size=144115188075859968) failed (error
code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call
last)
/Users/wstein/sage/install/sage-5.0.beta2/devel/sage-git/sage/<ipython
console> in <module>()
/Users/wstein/sage/install/sage-5.0.beta2/local/lib/python2.7/site-
packages/sage/rings/integer.so in sage.rings.integer.Integer.__pow__
(sage/rings/integer.c:12958)()
RuntimeError: Segmentation fault
sage: a = 2^(2^60)
------------------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component of Sage has a bug
in it and is not properly wrapped with sig_on(), sig_off(). You might
want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate.
------------------------------------------------------------------------
/Users/wstein/sage/install/sage-5.0.beta2/spkg/bin/sage: line 304: 64816
Segmentation fault: 11 sage-ipython "$@" -i
You have new mail in /var/mail/wstein
deep:sage wstein$
}}}
I don't know if MPIR even provides a way of properly dealing with this
sort of thing.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12266#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.