bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: seg fault in mpz_root patch


From: Torbjorn Granlund
Subject: Re: seg fault in mpz_root patch
Date: 19 Dec 2002 02:17:49 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Jason Moxham <address@hidden> writes:

  patch against gmp-4.1.1 attached
  
  --- gmp-4.1.1/mpn/generic/rootrem.c   2002-12-13 02:27:44.000000000 +0000
  +++ rootrem.c 2002-12-13 02:16:41.000000000 +0000
  @@ -65,7 +65,16 @@
     TMP_DECL (marker);
   
     TMP_MARK (marker);
  -  pp = TMP_ALLOC_LIMBS (un + 2);
  +  
  +  /*
  +     As the approximate root can be larger than the actual root by at most
  +     a factor of 2 , we need to allow space for another "nth" bits when 
  +     powering it using mpn_pow_1 , this is a large overestimate that only
  +     applies in rare cases i.e. when k is large and the root is small
  +     FIXME : change this awful allocation before gmp 4.2
  +  */
  +  
  +  pp = TMP_ALLOC_LIMBS (un + 2 + (nth - 1) / GMP_NUMB_BITS + 1);
   
     count_leading_zeros (cnt, up[un - 1]);
     unb = un * GMP_NUMB_BITS - cnt + GMP_NAIL_BITS;

Here is what I believe to be a better patch:

Attachment: pat
Description: Binary data

-- 
Torbjörn

reply via email to

[Prev in Thread] Current Thread [Next in Thread]