[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gmp-announce
Subject:    AMD K6 assembler GCD bug
From:       user42 () zip ! com ! au (Kevin Ryde)
Date:       2004-04-09 1:25:45
Message-ID: 29y8p8a8lz.fsf () king ! swox ! se
[Download RAW message or body]

Alas, a bug in the AMD K6 assembler code has been discovered, causing
wrong results from mpz_gcd and other functions involving GCDs.

Hosts "k6-*-*", "k62-*-*" and "k63-*-*" are affected, dating back to
the introduction of the code in gmp 4.0.

Patch below for mpn/x86/k6/gcd_finda.asm.


The program k6gcd.c below exhibits the bug.  You can use it (or the
numbers in it) to check whether you're affected and/or have
successfully patched.  The gcd of the values is 5, but the bug causes
it to come out as 1.

We believe in general the bug will bite rather rarely, and that the
wrong result will still be a divisor of the inputs, but not the
greatest possible divisor.


All folloups or queries to gmp-discuss@swox.com please.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcd_finda.asm.jbe.diff
Type: text/x-patch
Size: 215 bytes
Desc: not available
Url : /list-archives/gmp-announce/attachments/20040407/d5d71e9d/gcd_finda.asm.jbe.bin
-------------- next part --------------
#include "gmp.h"

int
main (void)
{
  mpz_t a, b, g;
  mpz_init_set_str (a, \
"3FFC000007FFFFFFFFFF00000000003F83FFFFFFFFFFFFFFF80000000000000001", 16);  \
mpz_init_set_str (b, \
"1FFE0007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000000000000000001", \
16);  mpz_init (g);
  mpz_gcd (g, a, b);
  gmp_printf ("expect result 5, the result is %Zd\n", g);
  return 0;
}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic