Bug 1002257 - mpz_gcdext() function does not provide expected results
mpz_gcdext() function does not provide expected results
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gmp (Show other bugs)
6.4
x86_64 Linux
unspecified Severity low
: rc
: ---
Assigned To: Frantisek Kluknavsky
BaseOS QE - Apps
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-28 14:15 EDT by Steve Simpson
Modified: 2014-11-06 09:36 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-11-06 09:36:21 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Source file to mpz_gcdext() from libgmp (1.23 KB, text/plain)
2013-08-28 14:15 EDT, Steve Simpson
no flags Details

  None (edit)
Description Steve Simpson 2013-08-28 14:15:45 EDT
Created attachment 791502 [details]
Source file to mpz_gcdext() from libgmp

Description of problem:
GMP's function mpz_gcdext() returns unexpected results.

This library solves the equation format A*S + B*T = G

One test case that highlighted the error was:
INPUT A=345, B=34587345
OUTPUT S=-14436457, T=144, G=15
EXPECTED S=-601519, T=6, G=15


In order to trace the error

I found this problem while building PHP 5.5 from source, I ran into the following failed test:
gmp_yum gcdext() basic tests [ext/gmp/tests/022.phpt]

To isolate the problem to the library or to PHP, I borrowed the attached C program and ran the calculation and it returned the same values as PHP.

I then built the latest version of GMP (5.1.2) and reran the test. This time it produced the expected results:
OUTPUT S=-601519, T=6, G=15


Version-Release number of selected component (if applicable):
gmp-4.3.1-7.el6_2.2.x86_64


How reproducible:
Either the PHP build test or by compiling the attached test program. Since the test program is a lot faster that is included here.


Steps to Reproduce:
1. Run the following commands on a test system
    gcc -lgmp -o gmptest gmptest.c
    echo 345 > input
    echo 34587345 >> input
    ./gmptest < input


Actual results:
a = 345
b = 34587345
g = 15
s = -14436457
t = 144
g =? 15
a*s + b*t=g
345 * -14436457 + 34587345 * 144 = 15


Expected results:
a = 345
b = 34587345
g = 15
s = -601519
t = 6
g =? 15
a*s + b*t=g
345 * -601519 + 34587345 * 6 = 15
Comment 2 RHEL Product and Program Management 2013-10-13 19:13:23 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.
Comment 3 Frantisek Kluknavsky 2014-11-06 09:36:21 EST
The first result satisfies the equation as well as the second result. I do not see a reason why is it called a bug.

Recent versions of gmp add another constraint - choose one of multiple solutions by minimizing 's'. Old gmp-4.3.1 in RHEL 6 does not have this constraint yet.

Note You need to log in before you can comment on or make changes to this bug.