lua-users home
lua-l archive

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



On Wed, Sep 26, 2018 at 11:50 AM Luke Horgan <horgan.l@husky.neu.edu> wrote:
On all the machines I've tried so far, for instance, the script Gé provided appears to produce identical output on every run.  I understand the Lua specification doesn't guarantee that behavior, but it would be handy to find a simple example that actually produces reliably non-deterministic results (or at least results that change with each executin).  If anyone has any ideas about how to do this, or has done it before, I'd really appreciate your input.

On my Macbook Pro I'm seeing this: (Lua 5.3.4)

$ lua d.lua
X7
X8
X9
X4
X3
X6
X5
X1
X2
X10
$ lua d.lua
X3
X4
X1
X2
X10
X9
X6
X5
X8
X7

Look at the routine 'makeseed' in ltable.c. When a new lua_State is created makeseed returns a 'random' value that's used in hash algorithms to make them less predictable.



--