Hi,

Valgrind revealed another possible error, in mpz_gcd, occurring for
specific inputs. In this case both operands have exactly size ==
alloc, and the second operand has exactly 64 trailing zero bits (this
is probably significant).

This is as before with MPIR 2.1.1 on a Pentium T4400, 64 bit Ubuntu,
gcc 4.4.5, and config.guess says penryn-unknown-linux-gnu.

Fredrik

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To post to this group, send email to mpir-devel@googlegroups.com.
To unsubscribe from this group, send email to 
mpir-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/mpir-devel?hl=en.

fredrik@scv:~/src/fltest$ valgrind --leak-check=full --show-reachable=yes 
./a.out
==18061== Memcheck, a memory error detector
==18061== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==18061== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for 
copyright info
==18061== Command: ./a.out
==18061== 
Version: 2.1.1
SIZE 2 2 -47 47
LIMB 0/2: 15370732829066920192
LIMB 1/2: 142430838635916748
LIMB 0/-47: 0
LIMB 1/-47: 8120485171012471201
LIMB 2/-47: 3651585150905889879
LIMB 3/-47: 3573637709654526044
LIMB 4/-47: 9354953330494539008
LIMB 5/-47: 16573493809005884248
LIMB 6/-47: 1564766564419085098
LIMB 7/-47: 7706467520104107156
LIMB 8/-47: 16003926258301304445
LIMB 9/-47: 844125293111205580
LIMB 10/-47: 5889166909755981407
LIMB 11/-47: 13382884345313515920
LIMB 12/-47: 3864324591451446818
LIMB 13/-47: 3209575445750115918
LIMB 14/-47: 14294284316229420009
LIMB 15/-47: 17468781208762374831
LIMB 16/-47: 14761171832480111038
LIMB 17/-47: 1501823175101545646
LIMB 18/-47: 4606802369442353986
LIMB 19/-47: 16515612824259262163
LIMB 20/-47: 4435020510466828251
LIMB 21/-47: 9497030456507225909
LIMB 22/-47: 8016534042466641022
LIMB 23/-47: 13931520368888706156
LIMB 24/-47: 6248055973115078328
LIMB 25/-47: 5828049744402323306
LIMB 26/-47: 15758953676775418463
LIMB 27/-47: 10015396866558229261
LIMB 28/-47: 13876719627406282890
LIMB 29/-47: 4128832281339318041
LIMB 30/-47: 15312685858527068571
LIMB 31/-47: 14600883679885208351
LIMB 32/-47: 3489173771109812274
LIMB 33/-47: 13073869386215888960
LIMB 34/-47: 1106216872790913461
LIMB 35/-47: 2637034895361634171
LIMB 36/-47: 16306639986428154698
LIMB 37/-47: 14731842869226982241
LIMB 38/-47: 9812338446331123490
LIMB 39/-47: 12228338623870014032
LIMB 40/-47: 2535585432374738937
LIMB 41/-47: 11347646027773831486
LIMB 42/-47: 11624965108032886152
LIMB 43/-47: 361218333002275217
LIMB 44/-47: 7502764222522353181
LIMB 45/-47: 1071408415206550693
LIMB 46/-47: 3
==18061== Invalid read of size 8
==18061==    at 0x54B6700: __gmpn_copyi (in /usr/local/lib/libmpir.so.8.2.1)
==18061==    by 0x40093D: main (gcdbug.c:31)
==18061==  Address 0x5e25568 is 0 bytes after a block of size 376 alloc'd
==18061==    at 0x4C28254: realloc (vg_replace_malloc.c:525)
==18061==    by 0x546046B: __gmp_default_reallocate (in 
/usr/local/lib/libmpir.so.8.2.1)
==18061==    by 0x5478390: __gmpz_realloc (in /usr/local/lib/libmpir.so.8.2.1)
==18061==    by 0x5478F70: __gmpz_set (in /usr/local/lib/libmpir.so.8.2.1)
==18061==    by 0x40088C: main (gcdbug.c:21)
==18061== 
==18061== 
==18061== HEAP SUMMARY:
==18061==     in use at exit: 0 bytes in 0 blocks
==18061==   total heap usage: 8 allocs, 8 frees, 832 bytes allocated
==18061== 
==18061== All heap blocks were freed -- no leaks are possible
==18061== 
==18061== For counts of detected and suppressed errors, rerun with: -v
==18061== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)

#include <stdio.h>
#include <stdlib.h>
#include <mpir.h>

int
main(void)
{
    mpz_t x, y, t, u;

    printf("Version: %s\n", mpir_version);

    mpz_init(x);
    mpz_init(y);
    mpz_init(t);
    mpz_init(u);

    mpz_set_str(x, "2627385228520578723183517397251784960", 10);
    mpz_set_str(y, "-52210306518047830402251600802917415148375245975500905649741489106427435273808661750417057582227360453081699166106028338159421591795140629433027825156055409585911443845093513183322920418796903950112747310801129654049060000551678316516239390511806265191718677248240264930326345567042532216695083378260988569056654652074579910352342063550515550861126572123891069711181111352429630986914813875036209671317861858071973941207629637780753461252137969024102363363527001571677814452206709093319862881687211316557020881507856082537871744253832748133250678019003301634549236818374867619330255716336548952632979418961729955027218815441623117835596009445256519253621472367251261451467304019994278577276182916100607523598783256654099085809930359704858474710294886352394135769054780273010600654391359883616498266029289544465550299816583233318434635480854362873178329557129916575750732231386261293629440", 10);

    mpz_set(t, x);
    mpz_set(u, y);

    printf("SIZE %d %d %d %d\n", t->_mp_size, t->_mp_alloc, u->_mp_size, u->_mp_alloc);

    long i;
    for (i = 0; i < t->_mp_size; i++)
        printf("LIMB %ld/%d: %lu\n", i, t->_mp_size, t->_mp_d[i]);
    for (i = 0; i < -(u->_mp_size); i++)
        printf("LIMB %ld/%d: %lu\n", i, u->_mp_size, u->_mp_d[i]);

    mpz_gcd(t, t, u);

    mpz_clear(t);
    mpz_clear(u);

    mpz_clear(x);
    mpz_clear(y);
}

Reply via email to