memory problem with GMP 5
Paul Zimmermann
Paul.Zimmermann at loria.fr
Sun Jan 24 19:07:34 CET 2010
> This is invalid usage of mpn_mul; the first operand must not have fewer
> limbs than the second operand. (This is not enforced unless you compile
> with --enable-alloca, and sometimes you might end up with the correct
> product. But such usage is defined to give undefined results and might
> as you noticed use excessive amounts of memory.
sorry for that.
> If you see excessive allocation also for correcrt usage of mpn_mul,
> please let us know.
I confirm I get identical results with the correct operand order:
GMP 4.3.2
start product
end product
Arena 0:
system bytes = 200704
in use bytes = 2512
Total (incl. mmap):
system bytes = 999411712
in use bytes = 999213520
max mmap regions = 6
max mmap bytes = 2207744000
GMP 5.0.0
start product
end product
Arena 0:
system bytes = 659456
in use bytes = 2512
Total (incl. mmap):
system bytes = 999870464
in use bytes = 999213520
max mmap regions = 6
max mmap bytes = 3504922624
GMP-5.0.0-20100123
start product
end product
Arena 0:
system bytes = 598016
in use bytes = 2512
Total (incl. mmap):
system bytes = 999809024
in use bytes = 999213520
max mmap regions = 6
max mmap bytes = 3005407232
Paul
#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"
int
main()
{
mp_ptr a, b, c;
mp_size_t sa = 25465231, sb = 36985114;
printf ("GMP %s\n", gmp_version);
a = malloc (sa * sizeof (mp_limb_t));
b = malloc (sb * sizeof (mp_limb_t));
c = malloc ((sa + sb) * sizeof (mp_limb_t));
mpn_random (a, sa);
mpn_random(b, sb);
printf ("start product\n");
fflush (stdout);
mpn_mul (c, b, sb, a, sa);
printf ("end product\n");
fflush (stdout);
malloc_stats ();
return 0;
}
More information about the gmp-bugs
mailing list