bug-gmp
[Top][All Lists]
Advanced

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

Re: mpz_powm crashes with modulus>2^2100000


From: Kevin Ryde
Subject: Re: mpz_powm crashes with modulus>2^2100000
Date: Thu, 13 Mar 2003 09:06:59 +1000
User-agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i386-pc-linux-gnu)

"Jens Kruse Andersen" <address@hidden> writes:
>
> I inserted the patch including all printf. My earlier sent test program still
> crashes with p=2^2100000+1 after outputting:
> Calling mpz_powm_ui...Done. Calling mpz_powm...k=1
> computing x^2

You might be running out of stack space, various temporaries are
allocated on the stack.

I don't know how to change the stack size on mingw.  But to have gmp
use malloc instead of the stack you can configure with

        ./configure --enable-alloca=malloc-notreentrant 

(Or malloc-reentrant if you need multi-threading or other reentrancy.)

> The prp test of p=3*2^2145353+1 had completed with my workaround. Just for
> speed, before finding the powm bug, I had written my own proth_mod optimized
> for modulus p=k*2^n+1, unsigned long k. This can be done with bitshifts and
> _ui operations and is extremely fast compared to the generic mpz_mod.

Yes, the general routines make no attempt to identify special forms
like that.  Currently you're best off making your calculation.

-- 
All followups to address@hidden please.




reply via email to

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