[Top][All Lists]

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

[Chicken-janitors] #767: random seed should be more random

From: Chicken Trac
Subject: [Chicken-janitors] #767: random seed should be more random
Date: Thu, 29 Dec 2011 21:26:47 -0000

#767: random seed should be more random
 Reporter:  zbigniew        |       Owner:  zbigniew
     Type:  defect          |      Status:  new     
 Priority:  major           |   Milestone:  4.8.0   
Component:  core libraries  |     Version:  4.7.x   
 Keywords:                  |  
 The default RNG is seeded with time(NULL) which only changes every 1
 second.  See CHICKEN_initialize in runtime.c.  Actually it only changes
 every 2 seconds, as C_randomize expects a C_word and the bottom bit is
 therefore destroyed.  Actually, on most platforms it may take up to a
 minute to change values, as rand() is crap.  Example:

 {{{while :; do date; csi -p '(random 60000)'; done}}}

 Instead it should be seeded with pid XOR seconds XOR milliseconds.  This
 is totally portable and doesn't involve replacing rand() with random() or
 anything else disruptive, just seeding with more random bits.

 I will put together a patch to do this, it is a trivial fix.

Ticket URL: <>
Chicken Scheme <>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

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