Hello,

I want to report a bug in gmp.

I got a program crash while trying to print a large integer number
(2^25964951).
Please note, that I could calculate this number. It is less then 10
million digits large and known as mersenne prime nr. 42 + 1.


Here are the detauls:
=-=-=-=-=-=-=-=-=-=-=-
GMP-Version: I could reproduce the error with 4.1.3 as well as 4.1.4. I
compiled both myself.

Test Program: included see below

error desription: The program crashes during a call to mpz_printf with a
"Speicherzugriffsfehler" (literally translated "Memory access
violation").
Originally I had this problem on a program which calculates big prime
numbers, then I programmed a simple test program which calculates M42
and tries to print it out afterwards. The program calls mpz_ui_pow_ui
without any obvious problem. When I try to print this number, I get the
descirbed crash. The problem seems not to be related to how the number
is created, it just appears when trying to print a number of a certain
size or bigger.

configuration options used when building GMP: -prefix=/usr

compiler version:
Es werden eingebaute Spezifikationen verwendet.
Ziel: x86_64-redhat-linux
Konfiguriert mit: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--host=x86_64-redhat-linux
Thread-Modell: posix
gcc-Version 4.0.1 20050727 (Red Hat 4.0.1-5)

output of uname -a:
Linux localhost.localdomain 2.6.13-1.1532_FC4 #1 Thu Oct 20 01:28:35 EDT
2005 x86_64 x86_64 x86_64 GNU/Linux

output of config.guess (gmp version 4.1.4):
x86_64-unknown-linux-gnu

output of configfsf.guess (gmp version 4.1.4):
x86_64-unknown-linux-gnu

Details on the test program:
Please find the attached c source of the program. I compiled it using

        g++ -o gmzPrintfTest gmzPrintfTest.c -lgmp -m64

It works this way:
1. Calculate Mersenne prime Nr. 42 + 1 which is 2^25964951.
2. try to print this number using gmp_printf

Is this a known problem? are there already workarounds?

Thank you in advance


-- 
Juergen Bullinger <[EMAIL PROTECTED]>
-- 
Juergen Bullinger <[EMAIL PROTECTED]>
/*
Testprogram for mpz_printf
*/

#include <stdio.h>

#include <gmp.h>
#include <sys/timeb.h>
                                                                                
#define FALSE   0
#define TRUE    1
#define MAXVALUE32BIT	4294967295

int main(void)
{
	mpz_t	number, basis, factor, treshold;
	int	readReturn;
	unsigned long	ulexp;
	FILE	*fp;
	FILE	*fpFactor;

	mpz_init(treshold);
	mpz_init(number);
	mpz_init(basis);
	mpz_init(factor);

	printf("after init before mpz_ui_pow_ui\n");
	fflush(stdout);

	mpz_ui_pow_ui(number, 2, 25964951);

	printf("after mpz_ui_pow_ui before mpz_printf\n");
	fflush(stdout);
	
	printf("Mersenne Number 42 is:\n");
	gmp_printf("%Zd\n", number);

        printf("ENDE!\n");
	fflush(stdout);

	mpz_clear(factor);
	mpz_clear(basis);
	mpz_clear(number);
	mpz_clear(treshold);

	return(0);
}

_______________________________________________
Bug-gmp mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gmp

Reply via email to