Hi 

Thanks for your bug report ,but this isn't a bug in the code,see this thread 
here for the reason , perhaps you can set Valgrind to ignore this type of 
thing , either that or just delete the two offending asm files

http://groups.google.com/group/mpir-
devel/browse_thread/thread/f60bcb31a828f03f/5b04ea24a10f7149?lnk=gst&q=core2+valgrind#5b04ea24a10f7149


Thanks
Jason





----------  Forwarded Message  ----------

Subject: Bug in Core 2 Assembler Code
Date: Tuesday, August 30, 2011, 11:56:34 pm
From: Tobias Jeske <tobias.je...@tu-harburg.de>
To: thempirt...@gmail.com

Hi all,

Valgrind reports some errors in my project. After having a closer look I
have found out that there seams to be a bug in the MPIR 2.4.0 Core 2
Assembler optimization code. I have made a short example containing the
bug (see code below).

This is what I have done to reproduce the bug...

- configured, compiled and installed MPIR on my laptop with a Core 2 CPU
running Ubuntu 11.04 x64
  - ./configure && make -j4 && sudo make install
  - compiled example
    gcc main.c -o main -lmpir
  - running Valgrind:
    valgrind ./main
    I get:

==3527== Memcheck, a memory error detector
==3527== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==3527== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright
info
==3527== Command: ./main
==3527== 
a: 1
b: 2
c: 3
==3527== Invalid read of size 8
==3527==    at 0x4E8DFCD: __gmpn_copyi
(in /usr/local/lib/libmpir.so.7.4.0)
==3527==    by 0x4007EC: main (in /home/.../mpir-2.4.0-bug/main)
==3527==  Address 0x543d098 is 0 bytes after a block of size 8 alloc'd
==3527==    at 0x4C28FAC: malloc (vg_replace_malloc.c:236)
==3527==    by 0x4E3B348: __gmp_default_allocate
(in /usr/local/lib/libmpir.so.7.4.0)
==3527==    by 0x4E4AC77: __gmpz_init
(in /usr/local/lib/libmpir.so.7.4.0)
==3527==    by 0x400753: main (in /home/.../mpir-2.4.0-bug/main)
==3527== 
a: 1
==3527== 
==3527== HEAP SUMMARY:
==3527==     in use at exit: 0 bytes in 0 blocks
==3527==   total heap usage: 12 allocs, 12 frees, 72 bytes allocated
==3527== 
==3527== All heap blocks were freed -- no leaks are possible
==3527== 
==3527== For counts of detected and suppressed errors, rerun with: -v
==3527== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)


- using MPIRs general C Code implementations
  ./configure --host=none && make -j4 && sudo make install
  gcc main.c -o main -lmpir
  valgrind ./main
  -> no errors...


If I choose higher numbers for a, b, c in the example program and MPIR
2.4.0 + Core 2 Assembler optimisations, Valgrind also reports no
errors...

Cheers,
Tobi

----------
#include <mpir.h>

void main()
{
    mpz_t a;
    mpz_t b;
    mpz_t c;
    mpz_init(a);
    mpz_init(b);
    mpz_init(c);

    mpz_set_ui(a, 1);
    mpz_set_ui(b, 2);
    mpz_set_ui(c, 3);

gmp_printf("a: %Zd\n", a);
gmp_printf("b: %Zd\n", b);
gmp_printf("c: %Zd\n", c);

        mpz_powm(a, b, b, c);

gmp_printf("a: %Zd\n", a);

    mpz_clear(a);
    mpz_clear(b);
    mpz_clear(c);
}
----------





-----------------------------------------

-- 
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.

Reply via email to