Closed wnortje closed 5 years ago
This seems like a CCL feature. Based on a quick inspection, it seems like the prngs aren't thread-safe so you shouldn't be sharing them across threads.
Thanks.
This works
(progn
(bordeaux-threads:make-thread
(lambda ()
(let* ((ironclad:*PRNG* (ironclad:make-prng :os)))
(format t "Thread1: ~A~%" (ironclad:make-random-salt)))))
(bordeaux-threads:make-thread
(lambda ()
(let ((ironclad:*PRNG* (ironclad:make-prng :os)))
(format t "Thread2: ~A~%" (ironclad:make-random-salt))))))
CCL raises error
Stream #<BASIC-FILE-BINARY-INPUT-STREAM ("/dev/urandom"/10 ISO-8859-1) #x30200241F31D> is private to #<PROCESS Anonymous thread(78) [Sleep] #x3020022B5D2D>
when the OS prng is used in multi-threaded applications, eg inside Hunchentoot request handlers.See https://ccl.clozure.com/docs/ccl.html#additional-keywords-for-open-and-make-socket
The code below shows the problem when run on CCL
The fortuna prng does work.
Clozure Common Lisp Version 1.12-dev/v1.12-dev.1 (LinuxX8664) Kubuntu 18.04