Help stabilising mini-gmp

Niels Möller nisse at lysator.liu.se
Mon Nov 14 22:06:05 UTC 2016


tg at gmplib.org (Torbjörn Granlund) writes:

> I created a web page for tracking the mini-gmp problems:
>
>   https://gmplib.org/devel/mini-gmp-status.html

>From that page:

  (P2) The seeding triggered by GMP_CHECK_RANDOMIZE is apparently based on
  seconds since epoch (with some funny skew). This is not good enough, as
  tests which run at the same time will get the same seed. 

Seed is currently time(NULL) + getpid(), so a loop like

  while GMP_CHECK_RANDOMIZE=0 ./t-foo ; do : ; done

will typically use an incrementing sequence of seeds, and not repeat
until the pid space wraps around.

Main gmp tests seem to use /dev/urandom if available, falling back to
gettimeofday if available, otherwise only the time function (no pid).

For mini-gmp tests, it was my intention that tests should be able to run
standalone from the gmp tree (assuming gmp and GNU make is installed on
the system, just "make -C tests check" in a mini-gmp source tree should
work). So it shouldn't depend on any configure tests, and ideally should
use only standard C functions, or the most mainstream functions outside
of the standard. (And depending on getpid is not ideal... but a
significant improvement over only time(NULL)).

Attempting to open /dev/urandom seems very reasonable to me. If we do
that, the remaining question is how elaborate a fallback we need if
opening fails.

If really needed, we could also propagate certain gmp configure values
in the make check-mini-gmp target, e.g., HAVE_GETPID and
HAVE_GETTIMEOFDAY.

/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list