On 30/04/2014 02:13, Alex Dyachenko wrote:
> Seeding a random MT generator copied with init_set causes a crash. The
> following code, linked with an MPIR 2.7.0alpha Lib Windows x64 Core2
> build, crashes on the last statement. It crashes whether or not the
> source generator was seeded before copying. No crash if using the LC
> algorithm.
>
> gmp_randstate_t a, b;
> gmp_randinit_mt(a); //problem specific to _mt only
> gmp_randseed_ui(a, 123456); //same result with or without this line
> gmp_randinit_set(b, a);
> gmp_randseed_ui(b, 123456); //causes access violation
This is because the intent of the gmp_randinit_set(b, a) call is to copy
the state of an already initialised and running MT generator.
This allows two (or more) identical sequences of random values to be
generated from a common initial state.
There is no sense in initialising after such a call since you get
exactly the same effect by calling gmp_randinit_mt(b).
However, we could (and maybe should) avoid the crash by allowing the
user to reseed in this way even though doing this is not really sensible
(this amounts to defensive programming on our part).
This behaviour is not Windows specific.
best regards,
Brian Gladman
--
You received this message because you are subscribed to the Google Groups
"mpir-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mpir-devel.
For more options, visit https://groups.google.com/d/optout.