Potential bug in mpz_import on AIX 5.3

Mike Pastore mike at oobak.org
Thu Sep 13 00:00:31 CEST 2007

GMP 4.2.2

The test program is essentially the example in the documentation for

  #include <gmp.h>

  int main(int argc, char *argv[]) {
    unsigned long a[20];
    mpz_t z;
    mpz_import(z, 20, 1, sizeof(a[0]), 0, 0, a);

Compiling this program with: 

  gcc -g example.c -o example -lgmp

And running it from the command line results in the following error:

  GNU MP: Cannot reallocate memory (old_size=2058812348 new_size=80)
  Resources lost

GMP was built with:

  ./configure ABI=32 --prefix=/sys/usr/local/graft-packages/gmp-4.2.2

gcc -v reports:

  Using built-in specs.
  Target: powerpc-ibm-aix5.3.0.0
  Configured with: /sys/usr/src/gcc-4.2.1/configure
    --with-ld=/usr/bin/ld --disable-nls --enable-languages=c,c++ 
    --prefix=/sys/usr/local --enable-threads
  Thread model: aix
  gcc version 4.2.1

uname -a reports:

  AIX rwxd48l1 3 5 00C9D68A4C00

This is AIX 5.3L ML5.

config.guess reports:


Here's the catch: Adding an mpz_init(z) before the mpz_import(z, ...)
completely resolves the problem. So either the documentation needs to be
updated, or the error message needs to be more descriptive (if
possible), or there's a bug under AIX that's preventing a
more-descriptive error message from being displayed. Please let me know
if I can provide any more information. Thank you!

Mike Pastore
mike at oobak.org

More information about the gmp-bugs mailing list