Opened 8 years ago

Closed 8 years ago

# divide by zero in facstd()

Reported by: Owned by: kroeker@… somebody minor 4-1-0 and higher factory 4-0-1 divide by zero facstd

### Description

failing example:

```LIB("primdec.lib");
ring rng = (0),(xa,xv,xr,xi),lp;
ideal I = -12887/7110*xv*xr*xi-631/1586*xr+2951/17148*xi+17517/1309,7105/28944*xa^2*xr-3248/1697*xa*xr,12162/10079*xa*xr*xi-6247/8857*xv-24273/12616;
list L = minAssGTZ (I) ;
```

error:

```error: math error: divide by zero
../../factory/int_intdiv.cc:74: In function `virtual InternalCF* InternalInteger::dividecoeff(InternalCF*, bool)':
failed assertion `invert || imm2int( c ) != 0'
Singular : signal 6 (v: 4011):
current line:>>  q = facstd(i);<<
Segment fault/Bus error occurred at 1 because of 202 (r:1415182941)

```

backtrace:

```#0  0x00000000004a2efb in debug (method=0) at ../../Singular/cntrlc.cc:463
#1  0x00000000004a2ac1 in sigsegv_handler (sig=6, s=...) at ../../Singular/cntrlc.cc:248
#2  <signal handler called>
#3  0x0000003203832625 in raise () from /lib64/libc.so.6
#4  0x0000003203833e05 in abort () from /lib64/libc.so.6
#5  0x00000000008fc2c9 in InternalInteger::dividecoeff (this=0x7f2806c26710, c=0x1, invert=false) at ../../factory/int_intdiv.cc:73
#6  0x000000000079b838 in CanonicalForm::operator/= (this=0x7f2806c29fe0, cf=...) at ../../factory/canonicalform.cc:762
#7  0x0000000000904412 in InternalPoly::divideTermList (firstTerm=0x7f2806c29fd8, coeff=..., lastTerm=@0x7f2806c284a8: 0x0) at ../../factory/int_poly.cc:2027
#8  0x0000000000901a5e in InternalPoly::dividecoeff (this=0x7f2806c28490, cc=0x1, invert=false) at ../../factory/int_poly.cc:1269
#9  0x000000000079b838 in CanonicalForm::operator/= (this=0x7fff01d5b430, cf=...) at ../../factory/canonicalform.cc:762
#10 0x0000000000897cee in precomputeLeadingCoeff (LCF=..., LCFFactors=..., alpha=..., evaluation=..., differentSecondVarLCs=@0x7fff01d5c1f8: 0x7f2806c3a6f8, lSecondVarLCs=1, y=...) at ../../factory/facFqFactorize.cc:1760
#11 0x000000000083b8a9 in multiFactorize (F=..., v=...) at ../../factory/facFactorize.cc:455
#12 0x00000000007c184c in ratSqrfFactorize (G=..., v=...) at ../../factory/facFactorize.h:62
#13 0x00000000007c20a2 in ratFactorize (G=..., v=..., substCheck=true) at ../../factory/facFactorize.h:148
#14 0x00000000007b5280 in factorize (f=..., issqrfree=false) at ../../factory/cf_factor.cc:584
#15 0x000000000074d17f in singclap_factorize (f=0x7f2806bffe10, v=0x0, with_exps=1, r=0x7f2806bdd640) at ../../../libpolys/polys/clapsing.cc:910
#16 0x00000000005e6edc in k_factorize (p=0x7f2806ba7bb0, rfac=@0x7fff01d5dbd8: 0x0, fac_copy=@0x7fff01d5dbd0: 0x0) at ../../../kernel/GBEngine/kstdfac.cc:251
#17 0x00000000005e8609 in bbafac (Q=0x0, strat=0x7f2806c008e0, FL=0x0) at ../../../kernel/GBEngine/kstdfac.cc:594
#18 0x00000000005e9d03 in kStdfac (F=0x7f2806c366f0, Q=0x0, h=isNotHomog, w=0x0, D=0x0) at ../../../kernel/GBEngine/kstdfac.cc:934
#19 0x00000000004bf5cc in jjFACSTD (res=0x7fff01d5de80, v=0x7fff01d5e228) at ../../Singular/iparith.cc:4069
#20 0x00000000004ce142 in iiExprArith1Tab (res=0x7fff01d5de80, a=0x7fff01d5e228, op=434, dA1=0xc68b70 <dArith1+1168>, at=274, dConvertTypes=0xc6c3a0 <dConvertTypes>) at ../../Singular/iparith.cc:7998
#21 0x00000000004ce86f in iiExprArith1 (res=0x7fff01d5de80, a=0x7fff01d5e228, op=434) at ../../Singular/iparith.cc:8127
#22 0x00000000004aa4a0 in yyparse () at grammar.y:631
#23 0x00000000004dd67d in iiAllStart (pi=0x7f2806b5c5b0,
p=0x7f2806bf6100 "parameter ideal i; parameter list #;  \n  ASSUME(1, hasFieldCoefficient(basering) );\n  ASSUME(1, not isQuotientRing(basering) ) ;\n  ASSUME(1, hasGlobalOrdering(basering) ) ;\n\n  if(size(i) == 0){return("...,
t=BT_proc, l=2105) at ../../Singular/iplib.cc:319
#24 0x00000000004ddb5c in iiPStart (pn=0x7f2806b5d100, v=0x7f2806ba7a80) at ../../Singular/iplib.cc:419
#25 0x00000000004de2a0 in iiMake_proc (pn=0x7f2806b5d100, pack=0x0, sl=0x7f2806ba7a80) at ../../Singular/iplib.cc:612
#26 0x00000000004b6ff1 in jjPROC (res=0x7fff01d61220, u=0x7f2806ba7f40, v=0x7f2806ba7a80) at ../../Singular/iparith.cc:1622
#27 0x00000000004cd781 in iiExprArith2TabIntern (res=0x7fff01d61220, a=0x7fff01d61558, op=40, b=0x7f2806b75e10, proccall=0, dA2=0xc6a6d0 <dArith2+4368>, at=271, bt=274, dConvertTypes=0xc6c3a0 <dConvertTypes>)
at ../../Singular/iparith.cc:7823
#28 0x00000000004cdfb0 in iiExprArith2 (res=0x7fff01d61220, a=0x7fff01d61558, op=40, b=0x7f2806b75e10, proccall=0) at ../../Singular/iparith.cc:7966
#29 0x00000000004c9636 in jjKLAMMER_PL (res=0x7fff01d61220, u=0x7fff01d61558) at ../../Singular/iparith.cc:7196
#30 0x00000000004cfdfd in iiExprArithM (res=0x7fff01d61220, a=0x7fff01d61558, op=40) at ../../Singular/iparith.cc:8458
#31 0x00000000004a9f12 in yyparse () at grammar.y:530
#32 0x00000000004dd67d in iiAllStart (pi=0x7f2806b69d80,
p=0x7f2806b43100 "parameter ideal i; parameter list #;  \n   ASSUME(0, hasFieldCoefficient(basering) );\n   ASSUME(0, not isQuotientRing(basering) ) ;\n   if(size(#)>0)\n   {\n      int keep_comp=1;\n   }\n\n  if(attrib(baseri"...,
t=BT_proc, l=5662) at ../../Singular/iplib.cc:319
#33 0x00000000004ddb5c in iiPStart (pn=0x7f2806b6c820, v=0x7f2806b29bb0) at ../../Singular/iplib.cc:419
#34 0x00000000004de2a0 in iiMake_proc (pn=0x7f2806b6c820, pack=0x0, sl=0x7f2806b29bb0) at ../../Singular/iplib.cc:612
#35 0x00000000004b6ff1 in jjPROC (res=0x7fff01d645c0, u=0x7f2806b4ece0, v=0x7f2806b29bb0) at ../../Singular/iparith.cc:1622
#36 0x00000000004cd781 in iiExprArith2TabIntern (res=0x7fff01d645c0, a=0x7fff01d648f8, op=40, b=0x7f2806bbdf40, proccall=0, dA2=0xc6a6d0 <dArith2+4368>, at=271, bt=274, dConvertTypes=0xc6c3a0 <dConvertTypes>)
at ../../Singular/iparith.cc:7823
#37 0x00000000004cdfb0 in iiExprArith2 (res=0x7fff01d645c0, a=0x7fff01d648f8, op=40, b=0x7f2806bbdf40, proccall=0) at ../../Singular/iparith.cc:7966
#38 0x00000000004c9636 in jjKLAMMER_PL (res=0x7fff01d645c0, u=0x7fff01d648f8) at ../../Singular/iparith.cc:7196
#39 0x00000000004cfdfd in iiExprArithM (res=0x7fff01d645c0, a=0x7fff01d648f8, op=40) at ../../Singular/iparith.cc:8458
#40 0x00000000004a9f12 in yyparse () at grammar.y:530
#41 0x00000000004a15b9 in main (argc=1, argv=0x7fff01d68748) at ../../Singular/tesths.cc:230

```

### comment:1 Changed 8 years ago by hannes

```ring rng = (0),(a,r,y),lp;
poly p=6763616388584366290648652046285691885594719724484472677309067264*r^2*y^2+5616999569898991479992807300802768920480756763027097521792000*a*r^2+1050905118785452282040368026432133723545990009331408295328000*a*y^2-378248727358308274080089594834896733059240357823039256248832000*a*r-43795857712240130488266504457125439820697371495662950934118400*r^2+163608941118646318307735934187520770159341773821249395906304000*a*y-1383134913264626178000864299239489233754982546453584186923676695*r*y-8193928177961412469433834405468925934995237937223882602905600*y^2+6367810121611767869542652053169469048067998622661953832698368000*a+3060511954662984730857438584651174062043423348932519514115312600*r-1323803846427854727025115717070654476174511088889047788918539700*y-53393508486383251995558861009165600389691795190142441598706117200
;
factorize(p);
```
Last edited 8 years ago by hannes (previous) (diff)

### comment:2 Changed 8 years ago by mlee

p is irreducible. But factorize does not recognizes this. However, if you change factorNums to 2 at line 281 in facFactorize.cc it will. That change might impair performance in some cases since you do twice as many bivariate factorizations as before. Otherwise you need to change precomputeLeadingCoeff to detect these cases and trigger more bivariate factorizations.

### comment:3 Changed 8 years ago by hannes

Resolution: → fixed new → closed

we try the first approach: see 37f64cbde0750bae160fe72bab5e190982a2273d

Note: See TracTickets for help on using tickets.