Bad random-state seed on Windows

Bug #1102748 reported by il71 on 2013-01-22
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

version: sbcl 1.1.3 x86-64

make-random-state does not work as expected when run from saved executable on windows.

The test:

(defun main ()
  (let ((*random-state* (make-random-state t)))
    (print (random 100))))

is fine when being run in REPL (linux,windows) or from saved executable (linux).

However, when Windows executable is build by

(sb-ext:save-lisp-and-die "test-random.exe" :executable t :toplevel #'main)

it produces several repeated numbers.

Stas Boukarev (stassats) on 2013-01-22
tags: added: os-windows
Stas Boukarev (stassats) wrote :

random-state is seeded with (get-internal-real-time) on windows, which will tend to be zero right at the start-up.

summary: - broken random-state on Windows
+ Bad random-state seed on Windows
Changed in sbcl:
importance: Undecided → Medium
status: New → Triaged
Stas Boukarev (stassats) wrote :

I committed a quick work around, now it also uses pid in conjunction with get-internal-real-time. The proper fix would come after SBCL is out of freeze.

Stas Boukarev (stassats) wrote :

commit 5f0bd05a15aaf93f46baf9b8aa3e9b0bfbca26ab
Author: Stas Boukarev <email address hidden>
Date: Fri Feb 1 19:57:41 2013 +0800

    Use CryptGenRandom as a random seed on Windows.

    Patch by Anton Kovalenko.

Changed in sbcl:
status: Triaged → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers