Bug found in nightbuilds

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Sun Feb 16 06:23:48 UTC 2014


Ciao,

Il Sab, 15 Febbraio 2014 4:55 pm, Torbjorn Granlund ha scritto:
> I traced it to a nn=0 call to the underlying pi1 call.  Dunno if that's
> problematic.

Yes, that's the problem. When n=1.

Code says:
  if (d & GMP_NUMB_HIGHBIT)
    { /* Normalized case */

      uh = up[--n]; /* Here n goes to 0 */
...
      if (BELOW_THRESHOLD (n, DIV_QR_1_NORM_THRESHOLD))
       {
          while (n > 0)
            udiv_qrnnd (...);
          return uh;
       }
      return mpn_div_qr_1n_pi1 (qp, up, n, uh, d, dinv);
}

The error arises when DIV_QR_1_NORM_THRESHOLD is zero, and the
BELOW_THRESHOLD is unconditionally false, so that the code doesn't simply
return uh, but calls mpn_div_qr_1n_pi1 with n = 0...

I disallowed zero DIV_QR_1_NORM_THRESHOLD with this patch:

https://gmplib.org/repo/gmp/rev/83258bea6f8f

and the  GMP_CHECK_RANDOMIZE=3526906869 test passes.

I believe that we should, for the same reasons, disallow zero 
DIV_QR_1_UNNORM_THRESHOLD in the /* Unnormalized case */ branch.

Regards,
m

-- 
http://bodrato.it/papers/



More information about the gmp-devel mailing list