Problem with gmp_randinit_set
Torbjörn Granlund
tg at gmplib.org
Tue Feb 14 00:41:08 UTC 2017
gmp_randinit_set(b, a);
gmp_randseed_ui(b, 123456); /* crashes */
AFAICT this is a gmp bug, but I don't rule out the possibility that
it's a user bug.
This looks like a GMP bug.
I never looked properly through the GMP PRNG code, and looking at it now
I don't immediately understand its structure. (This code was written by
an external contributor.)
What happens with your code is that GMP tries to call a seed application
function through a pointer, but that pointer was explicitly zeroed by
gmp_randinit_set (or in __gmp_randiset_mt to be exact).
One can change Mersenne_Twister_Generator_Noseed to
Mersenne_Twister_Generator to fix this (and move __gmp_randiset_mt to
randmts.c as mandated by Mersenne_Twister_Generator's scope), and then
your code supposedly runs without a crash. But I don't see why one ever
wants Mersenne_Twister_Generator_Noseed, which suggests my understanding
of this code is very poor indeed.
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-bugs
mailing list