Bug 1002257

Summary: mpz_gcdext() function does not provide expected results
Product: Red Hat Enterprise Linux 6 Reporter: Steve Simpson <ssimpson>
Component: gmpAssignee: Frantisek Kluknavsky <fkluknav>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.4   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-06 14:36:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Source file to mpz_gcdext() from libgmp none

Description Steve Simpson 2013-08-28 18:15:45 UTC
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 Program Management 2013-10-13 23:13:23 UTC
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 14:36:21 UTC
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.