Trac #16462: Fix upstream bug in Singular 3.1.6's multipolynomial factorization

=== singular-3.1.6.p2 (Leif Leonhardy, June 9th 2014) ===
 * #16462 Add patch to fix segfault in factorization of multivariate
   polynomials.  (Cherry-picked from upstream; cf. Singular trac #621.
   The pull request / commit referenced there isn't sufficient, as it
   isn't based on Singular 3.1.6.)
Trac #16462: Segfault in factorization of multivariate polynomials (Singular 3.1.6)

As reported on `sage-support`, the following segfaults in Sage 6.2:
{{{
u,v,w = var('u,v,w')
f(u,v,w) = 16*u^4*v^6*w^2 + 144*u^4*v^5*w^3 + 80*u^3*v^6*w^3 +
416*u^4*v^4*w^4 + 560*u^3*v^5*w^4 + 96*u^2*v^6*w^4 + 560*u^4*v^3*w^5 +
1296*u^3*v^4*w^5 + 368*u^2*v^5*w^5 + 16*u*v^6*w^5 + 384*u^4*v^2*w^6 +
1328*u^3*v^3*w^6 + 528*u^2*v^4*w^6 + 48*u*v^5*w^6 + 128*u^4*v*w^7 +
608*u^3*v^2*w^7 + 336*u^2*v^3*w^7 + 48*u*v^4*w^7 + 16*u^4*w^8 +
96*u^3*v*w^8 + 80*u^2*v^2*w^8 + 16*u*v^3*w^8 - 112*u^4*v^5*w^2 -
64*u^3*v^6*w^2 - 752*u^4*v^4*w^3 - 960*u^3*v^5*w^3 - 176*u^2*v^6*w^3 -
1648*u^4*v^3*w^4 - 3744*u^3*v^4*w^4 - 1344*u^2*v^5*w^4 - 64*u*v^6*w^4 -
1600*u^4*v^2*w^5 - 5744*u^3*v^3*w^5 - 3104*u^2*v^4*w^5 - 304*u*v^5*w^5 -
704*u^4*v*w^6 - 3840*u^3*v^2*w^6 - 3056*u^2*v^3*w^6 - 480*u*v^4*w^6 -
112*u^4*w^7 - 1008*u^3*v*w^7 - 1296*u^2*v^2*w^7 - 304*u*v^3*w^7 -
64*u^3*w^8 - 176*u^2*v*w^8 - 64*u*v^2*w^8 + 312*u^4*v^4*w^2 +
400*u^3*v^5*w^2 + 76*u^2*v^6*w^2 + 1540*u^4*v^3*w^3 + 3436*u^3*v^4*w^3 +
1360*u^2*v^5*w^3 + 72*u*v^6*w^3 + 2412*u^4*v^2*w^4 + 8788*u^3*v^3*w^4 +
5572*u^2*v^4*w^4 + 616*u*v^5*w^4 + 1500*u^4*v*w^5 + 8836*u^3*v^2*w^5 +
8524*u^2*v^3*w^5 + 1540*u*v^4*w^5 + 316*u^4*w^6 + 3484*u^3*v*w^6 +
5512*u^2*v^2*w^6 + 1548*u*v^3*w^6 + 400*u^3*w^7 + 1348*u^2*v*w^7 +
628*u*v^2*w^7 + 72*u^2*w^8 + 76*u*v*w^8 - 448*u^4*v^3*w^2 -
1004*u^3*v^4*w^2 - 420*u^2*v^5*w^2 - 24*u*v^6*w^2 - 1548*u^4*v^2*w^3 -
5672*u^3*v^3*w^3 - 3920*u^2*v^4*w^3 - 476*u*v^5*w^3 - 1544*u^4*v*w^4 -
9500*u^3*v^2*w^4 - 10280*u^2*v^3*w^4 - 2076*u*v^4*w^4 - 460*u^4*w^5 -
5696*u^3*v*w^5 - 10244*u^2*v^2*w^5 - 3280*u*v^3*w^5 - 1008*u^3*w^6 -
3884*u^2*v*w^6 - 2108*u*v^2*w^6 - 404*u^2*w^7 - 492*u*v*w^7 - 24*u*w^8 +
352*u^4*v^2*w^2 + 1304*u^3*v^3*w^2 + 952*u^2*v^4*w^2 + 124*u*v^5*w^2 +
764*u^4*v*w^3 + 4824*u^3*v^2*w^3 + 5604*u^2*v^3*w^3 + 1228*u*v^4*w^3 +
364*u^4*w^4 + 4836*u^3*v*w^4 + 9468*u^2*v^2*w^4 + 3332*u*v^3*w^4 +
1316*u^3*w^5 + 5568*u^2*v*w^5 + 3356*u*v^2*w^5 + 928*u^2*w^6 +
1252*u*v*w^6 + 124*u*w^7 - 144*u^4*v*w^2 - 928*u^3*v^2*w^2 -
1132*u^2*v^3*w^2 - 264*u*v^4*w^2 - 148*u^4*w^3 - 2056*u^3*v*w^3 -
4264*u^2*v^2*w^3 - 1608*u*v^3*w^3 - 940*u^3*w^4 - 4252*u^2*v*w^4 -
2764*u*v^2*w^4 - 1116*u^2*w^5 - 1624*u*v*w^5 - 264*u*w^6 + 24*u^4*w^2 +
344*u^3*v*w^2 + 744*u^2*v^2*w^2 + 296*u*v^3*w^2 + 348*u^3*w^3 +
1652*u^2*v*w^3 + 1136*u*v^2*w^3 + 740*u^2*w^4 + 1140*u*v*w^4 + 296*u*w^5
- 52*u^3*w^2 - 256*u^2*v*w^2 - 184*u*v^2*w^2 - 256*u^2*w^3 - 412*u*v*w^3
- 184*u*w^4 + 36*u^2*w^2 + 60*u*v*w^2 + 60*u*w^3 - 8*u*w^2
print "Factor f : ",f.factor()
}}}

Likewise:
{{{
$ sage -singular
                     SINGULAR                                 /
Development
 A Computer Algebra System for Polynomial Computations       /   version
3-1-6
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Dec
2012
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> ring r = 0,(u,v,w),dp;
> poly f = 16*u^4*v^6*w^2+144*u^4*v^5*w^3+80*u^3*v^6*w^3+416*u^4*v^4*w^4
+560*u^3*v^5*w^4+96*u^2*v^6*w^4+560*u^4*v^3*w^5+1296*u^3*v^4*w^5+368*u^2
*v^5*w^5+16*u*v^6*w^5+384*u^4*v^2*w^6+1328*u^3*v^3*w^6+528*u^2*v^4*w^6+4
8*u*v^5*w^6+128*u^4*v*w^7+608*u^3*v^2*w^7+336*u^2*v^3*w^7+48*u*v^4*w^7+1
6*u^4*w^8+96*u^3*v*w^8+80*u^2*v^2*w^8+16*u*v^3*w^8-112*u^4*v^5*w^2-64*u^
3*v^6*w^2-752*u^4*v^4*w^3-960*u^3*v^5*w^3-176*u^2*v^6*w^3-1648*u^4*v^3*w
^4-3744*u^3*v^4*w^4-1344*u^2*v^5*w^4-64*u*v^6*w^4-1600*u^4*v^2*w^5-5744*
u^3*v^3*w^5-3104*u^2*v^4*w^5-304*u*v^5*w^5-704*u^4*v*w^6-3840*u^3*v^2*w^
6-3056*u^2*v^3*w^6-480*u*v^4*w^6-112*u^4*w^7-1008*u^3*v*w^7-1296*u^2*v^2
*w^7-304*u*v^3*w^7-64*u^3*w^8-176*u^2*v*w^8-64*u*v^2*w^8+312*u^4*v^4*w^2
+400*u^3*v^5*w^2+76*u^2*v^6*w^2+1540*u^4*v^3*w^3+3436*u^3*v^4*w^3+1360*u
^2*v^5*w^3+72*u*v^6*w^3+2412*u^4*v^2*w^4+8788*u^3*v^3*w^4+5572*u^2*v^4*w
^4+616*u*v^5*w^4+1500*u^4*v*w^5+8836*u^3*v^2*w^5+8524*u^2*v^3*w^5+1540*u
*v^4*w^5+316*u^4*w^6+3484*u^3*v*w^6+5512*u^2*v^2*w^6+1548*u*v^3*w^6+400*
u^3*w^7+1348*u^2*v*w^7+628*u*v^2*w^7+72*u^2*w^8+76*u*v*w^8-448*u^4*v^3*w
^2-1004*u^3*v^4*w^2-420*u^2*v^5*w^2-24*u*v^6*w^2-1548*u^4*v^2*w^3-5672*u
^3*v^3*w^3-3920*u^2*v^4*w^3-476*u*v^5*w^3-1544*u^4*v*w^4-9500*u^3*v^2*w^
4-10280*u^2*v^3*w^4-2076*u*v^4*w^4-460*u^4*w^5-5696*u^3*v*w^5-10244*u^2*
v^2*w^5-3280*u*v^3*w^5-1008*u^3*w^6-3884*u^2*v*w^6-2108*u*v^2*w^6-404*u^
2*w^7-492*u*v*w^7-24*u*w^8+352*u^4*v^2*w^2+1304*u^3*v^3*w^2+952*u^2*v^4*
w^2+124*u*v^5*w^2+764*u^4*v*w^3+4824*u^3*v^2*w^3+5604*u^2*v^3*w^3+1228*u
*v^4*w^3+364*u^4*w^4+4836*u^3*v*w^4+9468*u^2*v^2*w^4+3332*u*v^3*w^4+1316
*u^3*w^5+5568*u^2*v*w^5+3356*u*v^2*w^5+928*u^2*w^6+1252*u*v*w^6+124*u*w^
7-144*u^4*v*w^2-928*u^3*v^2*w^2-1132*u^2*v^3*w^2-264*u*v^4*w^2-148*u^4*w
^3-2056*u^3*v*w^3-4264*u^2*v^2*w^3-1608*u*v^3*w^3-940*u^3*w^4-4252*u^2*v
*w^4-2764*u*v^2*w^4-1116*u^2*w^5-1624*u*v*w^5-264*u*w^6+24*u^4*w^2+344*u
^3*v*w^2+744*u^2*v^2*w^2+296*u*v^3*w^2+348*u^3*w^3+1652*u^2*v*w^3+1136*u
*v^2*w^3+740*u^2*w^4+1140*u*v*w^4+296*u*w^5-52*u^3*w^2-256*u^2*v*w^2-184
*u*v^2*w^2-256*u^2*w^3-412*u*v*w^3-184*u*w^4+36*u^2*w^2+60*u*v*w^2+60*u*
w^3-8*u*w^2;
> factorize(f);
Singular : signal 11 (v: 3160):
current line:>>factorize(f);<<
Segment fault/Bus error occurred at 2 because of 10202 (r:1402010493)
please inform the authors
trying to restart...
}}}

This is an upstream regression w.r.t. Singular 3.1.5 (included in Sage
6.1.1).

----

Upstream report: [http://www.singular.uni-kl.de:8002/trac/ticket/621]

----

=== singular-3.1.6.p2 (Leif Leonhardy, June 9th 2014) ===
 * #16462 Add patch to fix segfault in factorization of multivariate
   polynomials.  (Cherry-picked from upstream; cf. Singular trac #621.
   The pull request / commit referenced there isn't sufficient, as it
   isn't based on Singular 3.1.6.)

URL: http://trac.sagemath.org/16462
Reported by: leif
Ticket author(s): Leif Leonhardy
Reviewer(s): Volker Braun