Title | Test case seed generation is not random enough |
Status | closed |
Priority | nice |
Assigned user | Gareth Rees |
Organization | Ravenbrook |
Description | Test case seed generation in the function randomize() in testlib.c [1] is not very good, the output of time() is in seconds. This means that you if run a fast test case many times in succession, you get at most one different run per second. |
Analysis | The comment in testlib.c [1] line 269 says /* time_t uses an arbitrary encoding, but hopefully the low order */ /* 31 bits will have at least one bit changed from run to run. */ but time() "shall return the value of time in seconds since the Epoch" [2]. This should use a clock with higher resolution, perhaps gettimeofday(), but we need to check that it's available on all the platforms we support, and that we don't break compatibility of old random number seeds. |
How found | manual_test |
Evidence | [1] //info.ravenbrook.com/project/mps/master/code/testlib.c [2] < http://www.unix.com/man-page/posix/3/time/ > |
Observed in | 1.111.0 |
Created by | Gareth Rees |
Created on | 2013-05-15 16:46:24 |
Last modified by | Gareth Rees |
Last modified on | 2013-05-16 13:17:42 |
History | 2013-05-15 GDR Created. |
Change | Effect | Date | User | Description |
---|---|---|---|---|
181855 | closed | 2013-05-16 13:17:42 | Gareth Rees | EventClock has enough entropy on all the platforms we support that we can use it to choose the random number seed. |