Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 79870 - dev-libs/gmp-4.1.4 is broken for amd64
Summary: dev-libs/gmp-4.1.4 is broken for amd64
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-28 09:52 UTC by Andreas Pokorny
Modified: 2006-03-13 19:51 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
failure.cpp (failure.cpp,561 bytes, text/x-c++src)
2006-02-07 05:16 UTC, Daniel Black (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Pokorny 2005-01-28 09:52:45 UTC
the gmp library behves strange in several functions. The general adding substracting of large numbers works fine. But for example the function
mpz_powm_ui (mpz_t rop, mpz_t base, unsigned long int exp, mpz_t mod); which calculates the base raised by exp, modulo mod, fails. 
Here is a small test case, that shows that the function fails, depending on the parameters:
#include <iostream>
#include <gmpxx.h>
using namespace std;
int main()
{

  mpz_class val =29813298;

  {
    mpz_class m_p ("111");
    cout << "m_p is now " << m_p << endl;
    mpz_pow_ui ( m_p.get_mpz_t(),  val.get_mpz_t(),   14    );
    cout << "m_p is now " << m_p << endl;
  }

  {
    mpz_class m_p ("111"); 
    cout << "m_p is now " << m_p << endl;
    mpz_pow_ui(  m_p.get_mpz_t(),   val.get_mpz_t(),    1099511627791   );
    cout << "m_p is now " << m_p << endl;
  }
}


Reproducible: Always
Steps to Reproduce:
1.emerge gmp ( on amd64 )
2.g++ failure.cpp -lgmp -lgmpxx -o failure
3../failure

Actual Results:  
m_p is now 111
m_p is now
438268538590035726067581115327087342094765875085367552470940927814798831211089489304915274322875259305984
m_p is now 111
GNU MP: Cannot reallocate memory (old_size=16 new_size=80)
Aborted


Even if m_p gets a number large enough to store the result, the following call
will fail. since gmp still tries to reallocate.
Comment 1 Simon Stelling (RETIRED) gentoo-dev 2005-07-28 02:58:03 UTC
uhm, want to fix it yourself? *g*
Comment 2 Patrick McLean gentoo-dev 2006-02-01 09:06:48 UTC
This does not appear to be unique to amd64, that code segfaults on x86
Comment 3 Patrick McLean gentoo-dev 2006-02-01 10:31:18 UTC
Assigning to package maintainer, since this does not appear to be amd64 specific.
Comment 4 Daniel Black (RETIRED) gentoo-dev 2006-02-07 05:13:23 UTC
Still a problem?

I had to change the constant to 1099511627791ULL in the code to prevent a compile error.

dan@frog ~ $ g++ failure.cpp -lgmp -lgmpxx -o failure
dan@frog ~ $ ./failure
m_p is now 111
m_p is now 438268538590035726067581115327087342094765875085367552470940927814798831211089489304915274322875259305984
m_p is now 111
m_p is now 13066230545009234931899163930418822401899199274150838281346798221339086364947911849315251938139628322516574175232
dan@frog ~ $ env ACCEPT_KEYWORDS=~x86 emerge -pv gmp mpfr

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] dev-libs/gmp-4.1.4-r3  USE="-doc -nocxx" 0 kB
[ebuild   R   ] dev-libs/mpfr-2.2.0_p8  0 kB

Total size of downloads: 0 kB
dan@frog ~ $ emerge info
Portage 2.1_pre4-r1 (!/home/dan/gentoo/gentoo-x86/profiles/hardened/x86/2.6, gcc-3.4.5, glibc-2.3.5-r2, 2.6.14-gentoo-r5 i686)
=================================================================
System uname: 2.6.14-gentoo-r5 i686 AMD Athlon(tm)
Gentoo Base System version 1.12.0_pre15
distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.3 [disabled]
dev-lang/python:     2.3.5-r2, 2.4.2
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1-r1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r3
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe"
CHOST="i686-pc-linux-gnu"

I'm thinking this was fixed in _p8 http://www.mpfr.org/mpfr-current/
Comment 5 Daniel Black (RETIRED) gentoo-dev 2006-02-07 05:16:29 UTC
Created attachment 79111 [details]
failure.cpp
Comment 6 Tiago Freire 2006-02-08 08:29:36 UTC
I tested just for kicks, and version 4.1.4-r3 emerged fine on my amd64 system. see Bug 121968.
Comment 7 Daniel Black (RETIRED) gentoo-dev 2006-02-09 02:46:16 UTC
Andreas does it work for you?
Comment 8 Mark Loeser (RETIRED) gentoo-dev 2006-03-13 19:51:24 UTC
This looks fine now.  Please reopen if it is still a problem.