bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mpz_get_str triggers stack overflow


From: Ken Kahn
Subject: mpz_get_str triggers stack overflow
Date: Sat, 4 Sep 2004 20:34:42 +0100

Greetings,

The following code causes a stack overflow:

mpz_t ten_to_the_millionth;
mpz_init(ten_to_the_millionth);
mpz_ui_pow_ui(ten_to_the_millionth,10,1000000);
char *string = mpz_get_str(NULL,10,ten_to_the_millionth);

Changing 1000000 to 100000 and it runs fine.

I am using the gmp.dll (4.1.2) I obtained from http://www.cs.nyu.edu/exact/core/gmp/ . I'm running Windows XP and Visual Studio .NET.

The exact error is:

Unhandled exception at 0x0033e837 in toontalk.exe: 0xC00000FD: Stack overflow.

The Microsoft compiler uses a 1 MB stack by default. Increasing it to 10 MB fixes this problem until I need 10 to 10,000,000. (It works for 10 to the 3,000,000 and fails for 5,000,000.)

Is it that the mpz_get_str is recursive and needs a stack a bit larger than the resulting string? Is there any workaround? At least this should be documented, right?

Best,

-ken kahn





reply via email to

[Prev in Thread] Current Thread [Next in Thread]