Sage: Ticket #10833: Unhandled SIGSEGV on large expand of iterated polynomial
https://trac.sagemath.org/ticket/10833
<p>
Verified on 'Sage Version 4.6, Release Date: 2010-10-30' on my laptop and on nt.sagemath.org.
</p>
<p>
If I do this:
</p>
<pre class="wiki">R.<x,c> = PolynomialRing(QQ,2)
phi(x) = x^2 + c
def iterkate(n):
pol = x
for i in range(1,n):
pol = phi(pol)
return pol
g = expand(iterkate(7))
</pre><p>
Then I get this on the last command:
</p>
<pre class="wiki">------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component
of Sage has a bug in it (typically accessing invalid memory)
or 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 (sorry).
------------------------------------------------------------
</pre><p>
But if I do this
</p>
<pre class="wiki">R.<x,c> = PolynomialRing(QQ,2)
g = expand( (((((x^2 + c)^2 + c)^2 + c)^2 + c)^2 + c)^2 + c )
</pre><p>
Then it is perfectly happy and g is a degree 64 polynomial (but in both cases it's the same polynomial I'm asking it to expand!). In the first example, it will crash if the "7" is anything above about 6. At 6, it is unreliable, and crashes sometimes. 5 and lower seems fine. I wasn't sure how to pare down to a more minimal example, given the circumstances.
</p>
<p>
It's entirely possible I'm doing something stupid here and interacting with sage in a bad way. If so, it's still a bug, but I'd love to know what I'm doing that sage doesn't like.
</p>
<p>
Anyway, here's some debug info:
</p>
<pre class="wiki">Program received signal SIGSEGV, Segmentation fault.
0x03b3c3f5 in void std::__unguarded_linear_insert<__gnu_cxx::__normal_iterator<GiNaC::expair*,
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >,
GiNaC::expair, GiNaC::expair_rest_is_less>(__gnu_cxx::__normal_iterator<GiNaC::expair*,
std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >, GiNaC::expair, GiNaC::expair_rest_is_less) ()
from /usr/local/lib/sage-4.1.1-linux-Ubuntu_9.04-i686-Linux/local/lib/libpynac-0.2.so.1
Current language: auto
The current source language is "auto; currently c++".
</pre>en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/10833
Trac 1.1.6vbraunMon, 28 Feb 2011 14:38:29 GMTstatus, cc changed
https://trac.sagemath.org/ticket/10833#comment:1
https://trac.sagemath.org/ticket/10833#comment:1
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_info</em>
</li>
<li><strong>cc</strong>
<em>jpflori</em> <em>burcin</em> added
</li>
</ul>
<p>
This seems to be a duplicate of <a class="closed ticket" href="https://trac.sagemath.org/ticket/9880" title="defect: Pynac comparison functions do not provide a SWO (closed: fixed)">#9880</a>. Please try with Sage-4.6.1 and let us know if the bug persists.
</p>
TicketdsmMon, 28 Feb 2011 14:53:48 GMT
https://trac.sagemath.org/ticket/10833#comment:2
https://trac.sagemath.org/ticket/10833#comment:2
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/10833#comment:1" title="Comment 1">vbraun</a>:
</p>
<blockquote class="citation">
<p>
This seems to be a duplicate of <a class="closed ticket" href="https://trac.sagemath.org/ticket/9880" title="defect: Pynac comparison functions do not provide a SWO (closed: fixed)">#9880</a>. Please try with Sage-4.6.1 and let us know if the bug persists.
</p>
</blockquote>
<p>
FWIW I see crashes on 4.6.1 and 4.6.2.rc0; I tried to apply the patches from <a class="closed ticket" href="https://trac.sagemath.org/ticket/9880" title="defect: Pynac comparison functions do not provide a SWO (closed: fixed)">#9880</a> but no luck.
</p>
TicketvbraunMon, 28 Feb 2011 15:02:33 GMT
https://trac.sagemath.org/ticket/10833#comment:3
https://trac.sagemath.org/ticket/10833#comment:3
<p>
On Fedora 14 x86_64 + Sage-4.6.2.rc1, I don't get any error with <code>expand(iterkate(9))</code>. Running <code>expand(iterkate(10))</code> eats up all of my 12 GB of ram but doesn't segfault.
</p>
TicketdsmMon, 28 Feb 2011 15:21:27 GMT
https://trac.sagemath.org/ticket/10833#comment:4
https://trac.sagemath.org/ticket/10833#comment:4
<p>
On OS X 10.6.6, 4.6.2.rc0 under -gdb:
</p>
<pre class="wiki">sage: g = expand(iterkate(6))
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x000000010789eb2e in GiNaC::mul::compare ()
(gdb) backtrace
#0 0x000000010789eb2e in GiNaC::mul::compare ()
#1 0x00000001078079df in std::__unguarded_linear_insert<__gnu_cxx::__normal_iterator<GiNaC::expair*, std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >, GiNaC::expair, GiNaC::expair_rest_is_less> ()
#2 0x000000010780a3b5 in std::__final_insertion_sort<__gnu_cxx::__normal_iterator<GiNaC::expair*, std::vector<GiNaC::expair, std::allocator<GiNaC::expair> > >, GiNaC::expair_rest_is_less> ()
#3 0x0000000107804d1b in GiNaC::expairseq::canonicalize ()
#4 0x0000000107804d4c in GiNaC::expairseq::construct_from_epvector ()
#5 0x00000001077bf580 in GiNaC::add::add ()
#6 0x00000001077bf6d0 in GiNaC::add::expand ()
#7 0x00000001077fd165 in GiNaC::ex::expand ()
#8 0x0000000107deeb7f in __pyx_pf_4sage_8symbolic_10expression_10Expression_expand (__pyx_v_self=0x10c9cf170, __pyx_args=0x10023c050, __pyx_kwds=<value temporarily unavailable, due to optimizations>) at sage/symbolic/expression.cpp:13836
#9 0x00000001000b6472 in PyEval_EvalFrameEx ()
#10 0x00000001000b9002 in PyEval_EvalCodeEx ()
#11 0x00000001000b61b5 in PyEval_EvalFrameEx ()
#12 0x00000001000b9002 in PyEval_EvalCodeEx ()
#13 0x00000001000b875e in PyEval_EvalFrameEx ()
#14 0x00000001000b9002 in PyEval_EvalCodeEx ()
[etc]
</pre>
TicketjpfloriMon, 28 Feb 2011 18:06:26 GMT
https://trac.sagemath.org/ticket/10833#comment:5
https://trac.sagemath.org/ticket/10833#comment:5
<p>
I tested on sage 4.6.1 (debian in a vm) and got similar segfaults (SIGSEGV and SIGBUS, from 6).
</p>
<p>
Installing the fixed pynac from <a class="closed ticket" href="https://trac.sagemath.org/ticket/9880" title="defect: Pynac comparison functions do not provide a SWO (closed: fixed)">#9880</a> seems to fix the problem (tested till 9).
</p>
<p>
I put the patched spkg here (<a class="ext-link" href="http://perso.telecom-paristech.fr/~flori/pynac-0.2.1-patched.spkg"><span class="icon"></span>http://perso.telecom-paristech.fr/~flori/pynac-0.2.1-patched.spkg</a>) if someone else wants to try it.
</p>
<p>
It ran until <code>expand(iterkate(9)) on sage 4.6.2.rc0 (on debian, real machine, intel quad core smthg), with 10 it ate too much memory.</code>
</p>
<p>
<code>So I guess it is the same (kind of) problem as in #9880 (so it should be marked as duplicate).</code>
</p>
<p>
The bug stated there "disappeared" with 4.6.1, that one seem to disappear with 4.6.2 but they are kind of random and other bug of this kind could still appear with new versions.
</p>
TicketburcinTue, 01 Mar 2011 13:22:51 GMTstatus, milestone changed; resolution set
https://trac.sagemath.org/ticket/10833#comment:6
https://trac.sagemath.org/ticket/10833#comment:6
<ul>
<li><strong>status</strong>
changed from <em>needs_info</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-4.6.2</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
<p>
Thanks for tracking this Jean-Pierre. I'll do my best to review your patch in <a class="closed ticket" href="https://trac.sagemath.org/ticket/9880" title="defect: Pynac comparison functions do not provide a SWO (closed: fixed)">#9880</a> in the next few days and make a new pynac release.
</p>
<p>
I'm closing this as a duplicate of <a class="closed ticket" href="https://trac.sagemath.org/ticket/9880" title="defect: Pynac comparison functions do not provide a SWO (closed: fixed)">#9880</a>.
</p>
Ticket