lua-users home
lua-l archive

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




On Sun, Sep 23, 2018 at 9:56 AM Tom Sutcliffe <tomsci@me.com> wrote:

If the GC step and mul parameters are set the same, then the GC will behave _mostly_ identically on any machine running the exact same Lua binary (in particular 32- and 64-bit builds will be different even when still on x86 - different architectures will have different sizes for data structures which will affect collection logic). You would have to control for anything discernibly different about the environment that scripts can detect - any API that could return a different-sized result on different machines (even down to eg localisation of date formats, if those APIs are exposed). And I'm assuming your subset of the language locks down most things that could have side-effects

The interpreter uses a randomized 'seed' for the hash, to make it harder to perform attacks using hash collisions. If you run this script multiple times the results are printed in a different order.

local T = {}
for i = 1, 10 do
T[("X%d"):format(i)] = 1
end
for k in pairs(T) do
print(k)
end

Another problem: you can 'observe' the garbage collector at work by using the __gc metamethod and/or weak tables, and a script's result can easily depend on whether a key or value is present in a weak table or whether the function referenced by __gc executes.

Out of the box Lua is quite non-deterministic 🤔


--
--