wbhart / mpir

Multiple Precision Integers and Rationals
GNU General Public License v3.0
229 stars 135 forks source link

Assertion failure in MPIR FFT #12

Closed wbhart closed 10 years ago

wbhart commented 10 years ago

Dan Grayson encountered the following assertion in Macaulay 2, coming from MPIR:

Macaulay2, version 1.5.0.1
with packages: ConwayPolynomials, Elimination, IntegralClosure, LLLBases, PrimaryDecomposition, ReesAlgebra, TangentCone

i1 : version

o1 = HashTable{architecture => x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     }
               build => x86_64-apple-darwin
               compile node name => thallium.home
               compile time => Apr 22 2013, 11:06:48
               compiler => gcc 4.8.0
               configure arguments =>  '--enable-encap' '--enable-download' '--enable-common-staging-area' 'CC=gcc -m64' 'CXX=g++ -m64' '--build=x86_64-apple-darwin' '--enable-debug' '--disable-optimize' '--prefix=/usr' 'build_alias=x86_64-apple-darwin'
               dumpdata => false
               endianness => dcba
               executable extension => 
               factory version => 3.1.6
               flint version => not present
               frobby version => 0.9.0
               gc version => 7.3 alpha 3
               givaro version => not present
               gmp version => not present
               host => x86_64-apple-darwin
               issue => 10.8
               libfac version => 3.1.6
               linbox version => not present
               M2 name => M2
               M2 suffix => 
               machine => x86_64-MacOS-10.8
               mpfr version => 3.1.2
               mpir version => 2.6.0
               mysql version => not present
               ntl version => 5.5.2
               operating system => MacOS
               operating system release => 10.8
               packages => Style Macaulay2Doc FirstPackage Parsing Classic Browse Benchmark Text SimpleDoc PackageTemplate PrimaryDecomposition FourierMotzkin Dmodules Depth Elimination GenericInitialIdeal IntegralClosure HyperplaneArrangements LexIdeals Markov NoetherNormalization Points ReesAlgebra Regularity SchurRings SymmetricPolynomials SchurFunctors SimplicialComplexes LLLBases TangentCone ChainComplexExtras Schubert2 PushForward LocalRings BoijSoederberg BGG Bruns InvolutiveBases ConwayPolynomials EdgeIdeals FourTiTwo StatePolytope Polyhedra Polymake gfanInterface PieriMaps Normaliz Posets XML OpenMath SCSCP RationalPoints MapleInterface ConvexInterface SRdeformations NumericalAlgebraicGeometry BeginningMacaulay2 FormalGroupLaws Graphics WeylGroups HodgeIntegrals Cyclotomic Binomials Kronecker Nauty ToricVectorBundles ModuleDeformations PHCpack SimplicialDecomposability BooleanGB AdjointIdeal Parametrization Serialization NAGtypes NormalToricVarieties DGAlgebras Graphs GraphicalModels BIBasis KustinMiller Units MonomialMultiplierIdeals NautyGraphs VersalDeformations CharacteristicClasses RandomObjects RandomPlaneCurves RandomSpaceCurves RandomGenus14Curves RandomCanonicalCurves RandomCurves TensorComplexes MonomialAlgebras QthPower EliminationMatrices EllipticIntegrals Triplets
               pari version => 2.5.3
               pointer size => 8
               python version => not present
               readline version => 6.0
               scscp version => not present
               threads => false
               VERSION => 1.5.0.1

o1 : HashTable

i2 : sqrt 2p3000000
mulmod_2expp1_basecase.c:51: GNU MP assertion failed: !((xp) + (n) > (yp) && (yp) + (n) > (xp))

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x1903 of process 5959]
0x00007fff91e34212 in __pthread_kill () from i386:x86-64
(gdb) where
#0  0x00007fff91e34212 in __pthread_kill () from i386:x86-64
#1  0x00007fff8fbd5b54 in pthread_kill () from i386:x86-64
#2  0x00007fff8fc19dce in abort () from i386:x86-64
#3  0x0000000100a20ea0 in __gmp_assert_fail (filename=<optimized out>, linenum=<optimized out>, 
    expr=0x100b08158 "!((xp) + (n) > (yp) && (yp) + (n) > (xp))") at assert.c:49
#4  0x0000000100a4a430 in __gmpn_mulmod_2expp1_basecase (xp=0x10fe4e848, yp=<optimized out>, zp=<optimized out>, c=<optimized out>, b=<optimized out>, 
    tp=0x10fe538a8) at mulmod_2expp1_basecase.c:51
#5  0x0000000100a2b659 in __mpir_fft_mulmod_2expp1 (r1=0x107fdf180, i1=0x107fd66d0, i2=0x107fd38b0, r_limbs=1472, depth=5, w=92) at mulmod_2expp1.c:125
#6  0x0000000100a49e5d in __gmpn_mulmod_Bexpp1 (r=0x107fdf180, i1=<optimized out>, i2=<optimized out>, limbs=1472, tt=<optimized out>) at mulmod_bexpp1.c:74
#7  0x0000000100a2bef7 in __gmpn_mulmod_Bexpp1_fft (op=0x107fdf180, pl=1472, n=<optimized out>, nl=<optimized out>, m=<optimized out>, ml=1465)
    at mulmod_2expp1.c:238
#8  0x0000000100a63b37 in __gmpn_inv_div_qr_n (qp=0x107ffbfc0, np=0x107ff3560, dp=<optimized out>, dn=1465, inv=<optimized out>) at inv_div_qr_n.c:89
#9  0x0000000100a632fb in __gmpn_inv_div_qr (qp=0x107ffbfc0, np=0x107ff6328, nn=<optimized out>, dp=0x101fde8e0, dn=1465, dinv=<optimized out>)
    at inv_div_qr.c:181
#10 0x0000000100a52d25 in __gmpn_tdiv_qr (qp=<optimized out>, rp=0x107ff91e0, qxn=<optimized out>, np=<optimized out>, nn=2930, dp=<optimized out>, 
    dn=<optimized out>) at tdiv_qr.c:144
#11 0x0000000100a4db70 in mpn_intdivrem (qp=0x101fd8d50, np=0x10fbde8a8, nn=2930, dp=<optimized out>, dn=1465, qxn=0) at sqrtrem.c:96
#12 0x0000000100a4e043 in mpn_dc_sqrtrem (sp=0x101fd8d50, np=0x10fbdbae0, n=2930) at sqrtrem.c:259
#13 0x0000000100a4e00b in mpn_dc_sqrtrem (sp=0x101fd31c0, np=0x10fbd03c0, n=5860) at sqrtrem.c:256
#14 0x0000000100a4e00b in mpn_dc_sqrtrem (sp=0x101fc7aa8, np=0x10fbb9590, n=11719) at sqrtrem.c:256
#15 0x0000000100a4e00b in mpn_dc_sqrtrem (sp=0x101fb0c70, np=0x10fb8b920, n=23438) at sqrtrem.c:256
#16 0x0000000100a4e00b in mpn_dc_sqrtrem (sp=0x101f83000, np=0x10fb30040, n=46876) at sqrtrem.c:256
#17 0x0000000100a4e92e in __gmpn_sqrtrem (sp=0x101f83000, rp=0x10fb30040, np=0x11010b000, nn=<optimized out>) at sqrtrem.c:353
#18 0x0000000100690df3 in mpfr_sqrt (r=0x10349fb70, u=0x10349fd50, rnd_mode=MPFR_RNDN) at sqrt.c:141
#19 0x0000000100029895 in gmp_sqrt (x=0x10349fd50) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/gmp.d:1033
#20 0x00000001000eb47b in sqrt_1 (a=0x110087a30) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/actors3.d:1075
#21 0x00000001000a63cc in evaluate_eval (c=0x10349fdb0) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/evaluate.d:1270
#22 0x00000001000a9148 in evaluate_evalexcept (c=0x10349fdb0) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/evaluate.d:1404
#23 0x00000001001c87c5 in readeval4 (file=0x110075bc0, printout=1 '\001', dictionary=0x10346b210, returnLastvalue=0 '\000', 
    stopIfBreakReturnContinue=0 '\000', returnIfError=0 '\000') at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:176
#24 0x00000001001c9c9b in readeval3 (file=0x110075bc0, printout=1 '\001', dc=0x110075c10, returnLastvalue=0 '\000', stopIfBreakReturnContinue=0 '\000', 
    returnIfError=0 '\000') at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:270
#25 0x00000001001ca936 in loadprint (filename=0x1028703f0, dc=0x110075c10, returnIfError=0 '\000')
    at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:341
#26 0x00000001001cba10 in commandInterpreter_2 (e=0x101ec8d70) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:458
#27 0x00000001000a63cc in evaluate_eval (c=0x10346b630) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/evaluate.d:1270
#28 0x00000001000a6ee2 in evaluate_eval (c=0x10346b690) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/evaluate.d:1302
#29 0x00000001000a8851 in evaluate_eval (c=0x1100723f0) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/evaluate.d:1380
#30 0x00000001000a9148 in evaluate_evalexcept (c=0x1100723f0) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/evaluate.d:1404
#31 0x00000001001c87c5 in readeval4 (file=0x10296d440, printout=0 '\000', dictionary=0x10295fb10, returnLastvalue=0 '\000', 
    stopIfBreakReturnContinue=0 '\000', returnIfError=0 '\000') at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:176
#32 0x00000001001c9c9b in readeval3 (file=0x10296d440, printout=0 '\000', dc=0x10296d300, returnLastvalue=0 '\000', stopIfBreakReturnContinue=0 '\000', 
    returnIfError=0 '\000') at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:270
#33 0x00000001001c9da4 in readeval (file=0x10296d440, returnLastvalue=0 '\000', returnIfError=0 '\000')
    at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:280
#34 0x00000001001ccbfe in interp_process () at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/interp.d:594
#35 0x000000010001877c in interpFunc (vargs2=0x102927f90) at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/d/M2lib.c:551
#36 0x000000010037283a in ThreadTask::run (this=<error reading variable: Could not find the frame base for "ThreadTask::run(SupervisorThread*)".>, 
    thread=<error reading variable: Could not find the frame base for "ThreadTask::run(SupervisorThread*)".>)
    at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/system/supervisor.cpp:358
#37 0x0000000100372bb5 in SupervisorThread::threadEntryPoint (
    this=<error reading variable: Could not find the frame base for "SupervisorThread::threadEntryPoint()".>)
    at /Users/dan/src/M2/github/Macaulay2-M2-clone/M2/BUILD/dan/../../Macaulay2/system/supervisor.cpp:415
#38 0x0000000100372c38 in ?? ()
(gdb) 
wbhart commented 10 years ago

This looks to be a bug in the way inv_div calls mulmod_Bexpp1_fft.

wbhart commented 10 years ago

The problem was actually an incorrect pair of asserts in mulmod_2expp1_basecase. It has now been fixed.