[cmake-developers] OpenBSD and srand()/rand() changes

David Cole DLRdave at aol.com
Mon Dec 15 13:46:19 EST 2014


Looking at our own internal test suite usage of RANDOM_SEED leads to
the conclusion that we do not verify the sequences produced when
actually using RANDOM_SEED......

So, from our point of view, we don't really care about what effect
RANDOM_SEED has for our test suite. But I think we do still care that
it maintains its existing behavior for folks who are using it: some
clients may depend on it producing a deterministic sequence.

If you don't use RANDOM_SEED, you should get as random a sequence as
possible when using RANDOM. If you do use RANDOM_SEED, you should see
a deterministic sequence for subsequent uses of RANDOM in the same run
of cmake.


Just my opinion,
David C.


On Mon, Dec 15, 2014 at 11:48 AM, Rolf Eike Beer <eike at sf-mail.de> wrote:
> Brad King wrote:
>> On 12/14/2014 08:36 AM, Rolf Eike Beer wrote:
>> > The idea behind this API in OpenBSD is: if you are looking for the pseudo
>> > numbers you need to call srand_deterministic(), i.e. you must explicitely
>> > state that you want the not really random random numbers. Everyone else
>> > will get real random.
>>
>> CMake uses /dev/urandom on POSIX and wincrypt APIs on Windows to choose
>> the seed specifically to get "really" random behavior.  The *only* reason
>> we continue to use s/rand() at all is to support the RANDOM_SEED API in
>> string(RANDOM), AFAIK.
>>
>> One approach to dealing with this is to refactor the implementation of
>> string(RANDOM) to use non-deterministic APIs until RANDOM_SEED is used
>> and then use deterministic APIs after that.  That will get better random
>> values by default but still honor the existing API when it is used.
>
> Which is what we would get if we do not call srand_deterministic() on OpenBSD
> afaict. We would get weaker random numbers on other platforms, but I doubt
> this matters at all.
>
> Eike
> --
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers


More information about the cmake-developers mailing list