(random) isn't random

Bug #1600654 reported by alexdunn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Invalid
Undecided
Unassigned

Bug Description

The following command always writes 92:

```
sbcl --non-interactive --no-sysinit --no-userinit --eval '(write-line (write-to-string (random 256)))'
```

Within a session, successive invocations of (random 256) will return the same series of numbers: 92, 246, 238, 121, 44, 223, 5...

Tested with SBCL 1.3.7 and with the git HEAD at 5d2d20fd81585b17197b68376ce3d0062e383908 on Mac OS 10.11.5; and on SBCL 1.2.7 on CentOS 7.0.

Revision history for this message
Stas Boukarev (stassats) wrote :

Well, you have to seed the random state with (setf *random-state* (make-random-state t))...

Changed in sbcl:
status: New → Invalid
information type: Private Security → Public
Revision history for this message
alexdunn (dunn-alex) wrote :

OK, but what's the reason for not doing that automatically? Every other implementation of (random) I tested comes pre-seeded.

Revision history for this message
Stas Boukarev (stassats) wrote :

>_Every_ other
That was determined to be incorrect by testing Clozure CL, Clisp, C, C++.

Revision history for this message
alexdunn (dunn-alex) wrote :

> I tested

Namely ABCL, CMUCL, ECL.

But I guess I just happened to test an unusual set of implementations.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.